るりまサーチ

最速Rubyリファレンスマニュアル検索!
108件ヒット [101-108件を表示] (0.125秒)

別のキーワード

  1. _builtin define_method
  2. irb/input-method new
  3. irb/input-method gets
  4. irb/input-method encoding
  5. irb/input-method readable_atfer_eof?

ライブラリ

クラス

検索結果

<< < 1 2 >>

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

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

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

B.new.ok # => B

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

# remove_method の場合はスーパークラスに同名のメソッドがあると
# それが呼ばれる
c
lass B
remove_method :ok
end
B.new.ok # => A
//}

また、undef 文と undef_method の違いは、
メソッド名を String または Symbol で与えられること...
...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 #=> []
//}...
<< < 1 2 >>