るりまサーチ

最速Rubyリファレンスマニュアル検索!
24件ヒット [1-24件を表示] (0.032秒)
トップページ > クエリ:ruby[x] > クエリ:instance_eval[x] > クラス:Object[x]

別のキーワード

  1. csv instance
  2. _builtin instance_eval
  3. prime instance
  4. basicobject instance_eval
  5. syslog instance

ライブラリ

キーワード

検索結果

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...