24件ヒット
[1-24件を表示]
(0.032秒)
別のキーワード
ライブラリ
- ビルトイン (24)
キーワード
-
instance
_ variables (12) -
respond
_ to? (12)
検索結果
-
Object
# respond _ to?(name , include _ all = false) -> bool (31.0) -
オブジェクトがメソッド name を持つとき真を返します。
...は
Rubyの組み込みライブラリや標準ライブラリなど、C言語で実装されているメソッドのみです。
Rubyで実装されたメソッドで NotImplementedError が発生する場合は true を返します。
メソッドが定義されていない場合は、Object#resp......事になります。
//emlist[][ruby]{
class F
def hello
"Bonjour"
end
end
class D
private
def hello
"Guten Tag"
end
end
list = [F.new,D.new]
list.each{|it| puts it.hello if it.respond_to?(:hello)}
#=> Bonjour
list.each{|it| it.instance_eval("puts hello if it.respond_to?(:hell......implement template_method
end
puts ImplTemplateMethod.new.respond_to?(:template_method) # => true
# NotImplementedError が発生しているが、Rubyによる実装部のため true を返す
puts NotImplTemplateMethod.new.respond_to?(:template_method) # => true
# GNU/Linux で実行。C言語に... -
Object
# instance _ variables -> [Symbol] (13.0) -
オブジェクトのインスタンス変数名をシンボルの配列として返します。
...インスタンス変数名をシンボルの配列として返します。
//emlist[][ruby]{
obj = Object.new
obj.instance_eval { @foo, @bar = nil }
p obj.instance_variables
#=> [:@foo, :@bar]
//}
@see Object#instance_variable_get, Kernel.#local_variables, Kernel.#global_variables, Module.consta...