68件ヒット
[1-68件を表示]
(0.072秒)
種類
- インスタンスメソッド (43)
- 文書 (25)
ライブラリ
- ビルトイン (43)
クラス
- Method (12)
- Proc (12)
- TracePoint (7)
- UnboundMethod (12)
キーワード
検索結果
先頭5件
-
Proc
# parameters(lambda: nil) -> [object] (18244.0) -
Proc オブジェクトの引数の情報を返します。
...&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 = 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
prc = lambda{|x, y=42, *other|}
p prc.parameters(lambda: false) # => x], [:opt, :y], [:rest, :other
//}
@see Method#parameters, UnboundMethod#parameters... -
TracePoint
# parameters -> [object] (18242.0) -
現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。 フォーマットは Method#parameters と同じです。
...現在のフックが属するメソッドまたはブロックのパラメータ定義を返します。
フォーマットは Method#parameters と同じです。
@raise RuntimeError :call、:return、:b_call、:b_return、:c_call、:c_return
イベントのためのイベン......トフックの外側で実行した場合に発生します。
//emlist[例][ruby]{
def foo(a, b = 2)
end
TracePoint.new(:call) do |tp|
p tp.parameters # => a], [:opt, :b
end.enable do
foo(1)
end
//}
@see Method#parameters, UnboundMethod#parameters, Proc#parameters... -
Method
# parameters -> [object] (18220.0) -
Method オブジェクトの引数の情報を返します。
...t[例][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, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#parameters......st[例][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, :other], [:keyreq, :k_x], [:key, :k_y], [:keyrest, :k_other], [:block, :b
File.method(:symlink).parameters #=> req
//}
@see Proc#parameters... -
Proc
# parameters -> [object] (18220.0) -
Proc オブジェクトの引数の情報を返します。
...ck
& で指定されたブロック引数
//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... -
UnboundMethod
# parameters -> [object] (18220.0) -
UnboundMethod オブジェクトの引数の情報を返します。
...UnboundMethod オブジェクトの引数の情報を返します。
詳しくは Method#parameters を参照してください。
@see Proc#parameters, Method#parameters... -
NEWS for Ruby 2
. 7 . 0 (54.0) -
NEWS for Ruby 2.7.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...「Warning[:deprecated] = false」
としてください。
==== 番号指定パラメータ
* 番号指定パラメータ(Numbered parameters)がデフォルトのブロックの仮引数として
導入されました。 4475
//emlist[][ruby]{
[1, 2, 10].map { _1.to_s(16) } #=......すと
例外が発生するようになりました。
//emlist[][ruby]{
def bar
lambda
end
bar { puts "Hello" } #=> tried to create Proc object without a block (ArgumentError)
//}
==== その他の変更
* 始端なしRangeが実験的に導入されました。
caseやComparable#cl......これは deprecated です。 15575
この警告は「-W:no-deprecated」オプションで止められます。
//emlist{
def foo
class << Object.new
yield #=> warning: `yield' in class syntax will not be supported from Ruby 3.0. 15575
end
end
foo { p :ok }
//}
* 引数を転送す... -
NEWS for Ruby 2
. 6 . 0 (48.0) -
NEWS for Ruby 2.6.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。
...s がブロック引数にも反映されるようになりました。 14223
* Refinements が Object#public_send にも反映されるようになりました。 15326
* Refinements が Object#respond_to? にも反映されるようになりました。 15327
* rescue 節なしの else......* 排他的ファイルオープンを表すモード文字 'x' が追加されました。 11258
* Kernel
* 別名
* Object#then が Object#yield_self の別名として追加されました。 14594
* 新規オプション
* Kernel.#Complex, Kernel.#Float, Kernel.#Int......ePoint
* 新機能
* "script_compiled" イベントがサポートされました。 15287
* 新規メソッド
* TracePoint#parameters 14694
* TracePoint#instruction_sequence 15287
* TracePoint#eval_script 15287
* 変更されたメソッド
* TracePoint#en... -
メソッド呼び出し(super・ブロック付き・yield) (34.0)
-
メソッド呼び出し(super・ブロック付き・yield) * super * block * yield * block_arg * numbered_parameters * call_method
...メソッド呼び出し(super・ブロック付き・yield)
* super
* block
* yield
* block_arg
* numbered_parameters
* call_method
//emlist[例][ruby]{
foo.bar()
foo.bar
bar()
print "hello world\n"
print
Class.new
Class::new
//}
文法:
[式 `.'] 識別子 [`(' [[`*']......) do [`|' 式 ... `|'] 式 ... end
method(arg1, arg2, ...) `{' [`|' 式 ... `|'] 式 ... `}'
method(arg1, arg2, ..., `&' proc_object)
ブロック付きメソッドとは制御構造の抽象化のために用いられる
メソッドです。最初はループの抽象化の......#=> 1
def hoge
yield [1,2,3],4,5
end
hoge{|a, b, c| p a} #=> [1,2,3]
//}
http://www.a-k-r.org/d/2007-08.html#a2007_08_16_1
===[a:numbered_parameters] 番号指定パラメータ
ブロックに渡された値を参照するには、上記のようにブロックパラメータを定義する...