Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Ruby | Module | undef_method

概要

Module#undef_method(*name) -> self

詳細

このモジュールのインスタンスメソッド name を未定義にする。

サンプルコード
class Hoge
  def hoge
    'hoge'
  end
  print instance_methods(false), "\n"
  undef_method :hoge
  print instance_methods(false), "\n"
end

出力

$ ruby undef_method.rb
[:hoge]
[]