27件ヒット
[1-27件を表示]
(0.013秒)
検索結果
先頭4件
-
Proc
# parameters(lambda: nil) -> [object] (18155.0) -
Proc オブジェクトの引数の情報を返します。
...引数
: :keyreq
必須のキーワード引数
: :key
デフォルト値が指定されたオプショナルなキーワード引数
: :keyrest
** で指定された残りのキーワード引数
: :block
& で指定されたブロック引数
@param lambda true なら lambda として扱っ......= lambda{|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}
prc.parameters #=> x], [:opt, :y], [:rest, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
//}
//emlist[lambda: の例][ruby]{
prc = proc{|x, y=42, *other|}
p prc.parameters # => x], [:opt, :y], [:rest, :other
prc......parameters # => x], [:opt, :y], [:rest, :other
prc = proc{|x, y=42, *other|}
p prc.parameters(lambda: true) # => x], [:opt, :y], [:rest, :other
prc = lambda{|x, y=42, *other|}
p prc.parameters(lambda: false) # => x], [:opt, :y], [:rest, :other
//}
@see Method#parameters, UnboundMethod#parameters... -
Method
# parameters -> [object] (18131.0) -
Method オブジェクトの引数の情報を返します。
...ーワード引数
: :keyrest
** で指定された残りのキーワード引数
: :block
& で指定されたブロック引数
//emlist[例][ruby]{
m = Class.new{define_method(:m){|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}}.instance_method(:m)
m.parameters #=> x], [:opt, :y], [:rest, :ot......her], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#parameters... -
Proc
# parameters -> [object] (18131.0) -
Proc オブジェクトの引数の情報を返します。
...ショナルなキーワード引数
: :keyrest
** で指定された残りのキーワード引数
: :block
& で指定されたブロック引数
//emlist[例][ruby]{
prc = lambda{|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}
prc.parameters #=> x], [:opt, :y], [:rest, :other], [:keyreq, :k_......x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
//}
@see Method#parameters, UnboundMethod#parameters... -
NEWS for Ruby 2
. 7 . 0 (54.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...**)を足すことで警告を回避できます。
このように書けばRuby 3でも同じ意味で動きます。
//emlist[][ruby]{
def foo(key: 42); end; foo({key: 42}) # warned
def foo(**kw); end; foo({key: 42}) # warned
def foo(key: 42); end; foo(**{key: 42}) # OK
def foo(**kw)......; end; foo(**{key: 42}) # OK
//}
* キーワード引数を受け取るメソッドにキーワード引数を渡すが、必須引数
が不足している場合に、キーワード引数は最後の必須引数として解釈され、
警告が表示されます。警告を回避す......「Warning[:deprecated] = false」
としてください。
==== 番号指定パラメータ
* 番号指定パラメータ(Numbered parameters)がデフォルトのブロックの仮引数として
導入されました。 4475
//emlist[][ruby]{
[1, 2, 10].map { _1.to_s(16) } #=...