るりまサーチ

最速Rubyリファレンスマニュアル検索!
20件ヒット [1-20件を表示] (0.034秒)
トップページ > クエリ:args[x] > クエリ:ruby2_keywords[x]

別のキーワード

  1. fiddle ruby_free
  2. rbconfig ruby
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

クラス

キーワード

検索結果

Module#ruby2_keywords(method_name, ...) -> nil (18141.0)

For the given method names, marks the method as passing keywords through a normal argument splat. This should only be called on methods that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the method such that if the method is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the method to other methods.

...ames, marks the method as passing keywords through
a normal argument splat. This should only be called on methods that
accept an argument splat (`*args`) but not explicit keywords or a
keyword splat. It marks the method such that if the method is called
with keyword arguments, the final hash argum...
...aware that if this method is removed, the behavior of the
method will change so that it does not pass through keywords.

//emlist[例][ruby]{
module Mod
def foo(meth, *args, &block)
send(:"do_#{meth}", *args, &block)
end
ruby2_keywords
(:foo) if respond_to?(:ruby2_keywords, true)
end
//}...

Proc#ruby2_keywords -> proc (18141.0)

Marks the proc as passing keywords through a normal argument splat. This should only be called on procs that accept an argument splat (`*args`) but not explicit keywords or a keyword splat. It marks the proc such that if the proc is called with keyword arguments, the final hash argument is marked with a special flag such that if it is the final element of a normal argument splat to another method call, and that method call does not include explicit keywords or a keyword splat, the final element is interpreted as keywords. In other words, keywords will be passed through the proc to other methods.

...Marks the proc as passing keywords through a normal argument splat. This
should only be called on procs that accept an argument splat (`*args`)
but not explicit keywords or a keyword splat. It marks the proc such
that if the proc is called with keyword arguments, the final hash
argument is marked...
...so, be aware that if this method is removed, the behavior of the
proc will change so that it does not pass through keywords.

//emlist[][ruby]{
module Mod
foo = ->(meth, *args, &block) do
send(:"do_#{meth}", *args, &block)
end
foo.ruby2_keywords if foo.respond_to?(:ruby2_keywords)
end
//}...

Hash.ruby2_keywords_hash?(hash) -> bool (6185.0)

Module#ruby2_keywordsやProc#ruby2_keywordsによる ruby2_keywords フラグが設定されているかどうかを返します。

...Module#ruby2_keywordsやProc#ruby2_keywordsによる
ruby2_keywords
フラグが設定されているかどうかを返します。

このメソッドはデバッグや調査、シリアライゼーションのために本当に必要な場合のために
用意されていて、普通のプログ...
...れていません。

ruby 2.7.1 で追加されたため、ruby 2.7.0 では定義されていません。

//emlist[][ruby]{
ruby2_keywords
def foo(*args)
Hash.ruby2_keywords_hash?(args.last)
end
foo(k: 1) # => true
foo({k: 1}) # => false
//}

@see Module#ruby2_keywords, Proc#ruby2_keywords...

NEWS for Ruby 2.7.0 (18.0)

NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...されました。 10771
* 通常の引数分解でキーワード引数を渡すようにメソッドに印をつける
Module#ruby2_keywordsを追加しました。
古いRubyと互換性のある方法で全ての引数を転送する時に使えます。 16154
* 変更...
...* Proc
* 新規メソッド
* 通常の引数分解でキーワード引数を渡すようにprocに印をつける
Proc#ruby2_keywordsを追加しました。
古いRubyと互換性のある方法で全ての引数を転送する時に使えます。 16404

* Range...
...* rb_scan_argsの書式文字列の「:」はキーワード引数として扱われるようになりました。
キーワード引数の代わりに位置引数のハッシュとして渡されるとdeprecated警告が
出ます。

* ANYARGSを使ったC API宣言はANYARGSを使わ...