るりまサーチ

最速Rubyリファレンスマニュアル検索!
11件ヒット [1-11件を表示] (0.384秒)
トップページ > クエリ:_builtin[x] > クエリ:raise[x] > クエリ:puts[x] > クエリ:respond_to?[x]

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

ライブラリ

クラス

検索結果

Object#respond_to?(name, include_all = false) -> bool (26148.0)

オブジェクトがメソッド name を持つとき真を返します。

...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?(:hello, true)")}
#=> Bonjour
# Guten Tag

module Template
def main
start
template_method
finish
end

def start
puts
"start"
end

def...
...end

def finish
puts
"finish"
end
end

class ImplTemplateMethod
include Template
def template_method
"implement template_method"
end
end

class NotImplTemplateMethod
include Template

# not implement template_method
end

puts
ImplTemplateMethod.new.respond_to?(:template_method...
...生しているが、Rubyによる実装部のため true を返す
puts
NotImplTemplateMethod.new.respond_to?(:template_method) # => true
# GNU/Linux で実行。C言語による実装部のため false を返す
puts
File.respond_to?(:lchmod) # => false
//}

@see Module#method_defined?...