108件ヒット
[101-108件を表示]
(0.142秒)
別のキーワード
ライブラリ
- ビルトイン (108)
キーワード
-
private
_ instance _ methods (12) -
private
_ methods (12) -
protected
_ instance _ methods (12) -
protected
_ methods (12) -
public
_ instance _ methods (12) -
public
_ methods (12) -
undef
_ method (12)
検索結果
-
Module
# undef _ method(*name) -> self (12323.0) -
このモジュールのインスタンスメソッド name を未定義にします。
...k
puts 'B'
end
end
B.new.ok # => B
# undef_method の場合はスーパークラスに同名のメソッドがあっても
# その呼び出しはエラーになる
class B
undef_method :ok
end
B.new.ok # => NameError
# remove_method の場合はスーパークラスに同名のメソ......ss 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 #=> ["f......oo"]
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 #=> []
//}...