るりまサーチ

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

別のキーワード

  1. _builtin to_s
  2. openssl to_der
  3. openssl to_s
  4. _builtin to_a
  5. openssl to_pem

ライブラリ

クラス

検索結果

Method#to_proc -> Proc (18114.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 (18114.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"
//}...

Proc#lambda? -> bool (37.0)

手続きオブジェクトの引数の取扱が厳密であるならば true を返します。

...#=> false

# Method#to_proc によるものは lambda?が真となる
def m() end
method(:m).to_proc.lambda? #=> true

# Module#define_method は特別扱いで、
# これで定義されたメソッドの引数は常に厳密に取り扱われる
class
C
define_method(:d) {}
end
C.n...
...ew.d(1,2) #=> ArgumentError
C.new.method(:d).to_proc.lambda? #=> true

class
C
define_method(:e, &proc {})
end
C.new.e(1,2) #=> ArgumentError
C.new.method(:e).to_proc.lambda? #=> true
//}...