33件ヒット
[1-33件を表示]
(0.055秒)
キーワード
- lambda? (11)
-
source
_ location (11)
検索結果
-
Method
# to _ proc -> Proc (39121.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"
//}... -
Proc
# lambda? -> bool (68.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.new.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
//}... -
Proc
# source _ location -> [String , Integer] | nil (20.0) -
ソースコードのファイル名と行番号を配列で返します。
...by]{
# /path/to/target.rb を実行
proc {}.source_location # => ["/path/to/target.rb", 1]
proc {}.source_location # => ["/path/to/target.rb", 2]
(eval "proc {}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}
@see Method#source_location...