71件ヒット
[1-71件を表示]
(0.022秒)
別のキーワード
種類
- インスタンスメソッド (57)
- 特異メソッド (14)
ライブラリ
- ビルトイン (71)
検索結果
先頭5件
-
Proc
# lambda? -> bool (8071.0) -
手続きオブジェクトの引数の取扱が厳密であるならば true を返します。
...らば true を返します。
引数の取扱の厳密さの意味は以下の例を参考にしてください。
//emlist[例][ruby]{
# lambda で生成した Proc オブジェクトでは true
lambda{}.lambda? # => true
# proc で生成した Proc オブジェクトでは false
proc{}.lambda......? # => false
# Proc.new で生成した Proc オブジェクトでは false
Proc.new{}.lambda? # => false
# 以下、lambda?が偽である場合
# 余分な引数を無視する
proc{|a,b| [a,b]}.call(1,2,3) # => [1,2]
# 足りない引数には nil が渡される
proc{|a,b| [a,b]}.call(1) # =>......る
proc{|a,b| [a,b]}.call([1,2]) # => [1,2]
# lambdaの場合これらはすべて ArgumentError となる
# &が付いた仮引数で生成される Proc は lambda? が偽となる
def n(&b) b.lambda? end
n {} # => false
# &が付いた実引数によるものは、lambda?が元の Procオブ... -
Proc
# parameters(lambda: nil) -> [object] (8013.0) -
Proc オブジェクトの引数の情報を返します。
...Proc オブジェクトの引数の情報を返します。
Proc オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に対応した以下のような Symbol と、引数名を表す......定された残りのキーワード引数
: :block
& で指定されたブロック引数
@param lambda true なら lambda として扱ったとき、false なら lambda ではない Proc として
扱ったときの引数の情報を返します。
//emlist[例][ruby]{
prc = lambd......//emlist[lambda: の例][ruby]{
prc = proc{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = lambda{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = proc{|x, y=42, *other|}
p prc.parameters(lambda: true) # => x], [:opt, :y], [:rest, :other... -
Proc
# hash -> Integer (8007.0) -
self のハッシュ値を返します。
...self のハッシュ値を返します。
Proc オブジェクトの引数の情報を返します。
Proc オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に対応した以......素です。
//emlist[][ruby]{
prc = proc{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = lambda{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc = proc{|x, y=42, *other|}
p prc.parameters(lambda: true) # => x], [:opt, :y], [:rest, :other... -
Proc
# inspect -> String (8007.0) -
self の文字列表現を返します。
...self の文字列表現を返します。
可能なら self を生成したソースファイル名、行番号を含みます。
//emlist[例][ruby]{
p Proc.new {
true
}.to_s
# => "#<Proc:0x0x401a880c@-:3>"
//}... -
Proc
# to _ proc -> self (8007.0) -
self を返します。
...self を返します。
//emlist[例][ruby]{
pr = proc {}
p pr == pr.to_proc # => true
//}... -
Proc
# to _ s -> String (8007.0) -
self の文字列表現を返します。
...self の文字列表現を返します。
可能なら self を生成したソースファイル名、行番号を含みます。
//emlist[例][ruby]{
p Proc.new {
true
}.to_s
# => "#<Proc:0x0x401a880c@-:3>"
//}... -
Proc
. new -> Proc (8007.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。......ブロックを指定しなければ、このメソッドを呼び出したメソッドが
ブロックを伴うときに、それを Proc オブジェクトとして生成して返します。
ただし、ブロックを指定しない呼び出しは推奨されていません。呼び出し元の......上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p ar... -
Proc
. new { . . . } -> Proc (8007.0) -
ブロックをコンテキストとともにオブジェクト化して返します。
...定しない場合、Ruby 2.7 では
$VERBOSE = true のときには警告メッセージ
「warning: Capturing the given block using Proc.new is deprecated; use `&block` instead」
が出力され、Ruby 3.0 では
ArgumentError (tried to create Proc object without a block)
が発生します。......ブロックを指定しなければ、このメソッドを呼び出したメソッドが
ブロックを伴うときに、それを Proc オブジェクトとして生成して返します。
ただし、ブロックを指定しない呼び出しは推奨されていません。呼び出し元の......上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
//emlist[例][ruby]{
def foo
pr = Proc.new
pr.call(1)
end
foo {|arg| p arg }
# => 1
//}
これは以下と同じです。
//emlist[例][ruby]{
def foo
yield(1)
end
foo {|arg| p ar...