るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.056秒)
トップページ > クエリ:Class[x] > クエリ:methods[x] > クラス:Module[x] > クエリ:undef_method[x]

別のキーワード

  1. win32ole ole_methods
  2. win32ole ole_func_methods
  3. fileutils methods
  4. win32ole ole_get_methods
  5. win32ole ole_put_methods

ライブラリ

検索結果

Module#undef_method(*name) -> self (18174.0)

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

...//emlist[例][ruby]{
class
A
def ok
puts 'A'
end
end
class
B < A
def ok
puts 'B'
end
end

B.new.ok # => B

# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class
B
undef_method
:ok
end
B.new.ok #...
...
class
B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられることです。

//emlist[例][ruby]{
module
M1
def foo
end
def self.moo
undef foo
end
end
M1.instance_methods false...
...#=> ["foo"]
M1.moo
M1.instance_methods false #=> []
module
M2
def foo
end
def self.moo
undef_method
:foo
end
end
M2.instance_methods false #=> ["foo"]
M2.moo
M2.instance_methods false #=> []
//}...