るりまサーチ

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

別のキーワード

  1. argf.class each
  2. argf.class each_line
  3. argf.class lines
  4. argf.class to_a
  5. argf.class gets

ライブラリ

クラス

検索結果

Method#to_proc -> Proc (24220.0)

self を call する Proc オブジェクトを生成して返します。

...self を call する Proc オブジェクトを生成して返します。

//emlist[例][ruby]{
class
Foo
def foo
"foo"
end
end

m = Foo.new.method(:foo) # => #<Method: Foo#foo>
pr = m.to_proc # => #<Proc:0x007f874d026008 (lambda)>
pr.call # => "foo"
//}...

Object#to_proc -> Proc (24220.0)

オブジェクトの Proc への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。

...すが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。

//emlist[][ruby]{
def doing
yield
end

class
Foo
def to_proc
Proc.new{p 'ok'}
end
end

it = Foo.new
doing(&it) #=> "ok"
//}...