るりまサーチ

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

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method gets
  4. irb/input-method new
  5. matrix -

モジュール

オブジェクト

キーワード

検索結果

<< 1 2 3 ... > >>

Proc (38222.0)

ブロックをコンテキスト(ローカル変数のスコープやスタックフ レーム)とともにオブジェクト化した手続きオブジェクトです。

...手続きオブジェクトです。

Proc
は ローカル変数のスコープを導入しないことを除いて
名前のない関数のように使えます。ダイナミックローカル変数は
Proc
ローカルの変数として使えます。

Proc
がローカル変数のスコープ...
...[ruby]{
var = 1
$foo = Proc.new { var }
var = 2

d
ef foo
$foo.call
end

p foo # => 2
//}

===[a:should_use_next] 手続きを中断して値を返す

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャン...
...通り lambda で生成した手続きオブジェクトはメソッドと同じように振る舞う
ことを意図されているため、例外 LocalJumpError は発生しません。

//emlist[例][ruby]{
d
ef foo
Proc
.new { return }
end

foo.call
# => in `call': return from proc-closure (Loca...

Proc#ruby2_keywords -> proc (27377.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.

...ks 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...
...r 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.

This should only be used for procs that delegate keywords to another
method, and only...
...ards compatibility. As it does not exist in Ruby versions
before 2.7, check that the proc responds to this method before calling
it. Also, 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 = ->...

Proc#lambda? -> bool (27374.0)

手続きオブジェクトの引数の取扱が厳密であるならば true を返します。

...by]{
# 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) # => [1, nil]
# 配列1つだと展開される
proc
{|a,b| [a,b]}.call([1,2]) # => [1,2]
# lambdaの場合これらはすべて ArgumentErro...
...れる Proc は lambda? が偽となる
d
ef n(&b) b.lambda? end
n {} # => false

# &が付いた実引数によるものは、lambda?が元の Procオブジェクトから
# 引き継がれる
lambda(&lambda {}).lambda? #=> true
proc
(&lambda {}).lambda? #=> true
Proc
.new(&lambda {}).lambda? #=...

Proc#binding -> Binding (27334.0)

Proc オブジェクトが保持するコンテキストを Binding オブジェクトで返します。

...
Proc
オブジェクトが保持するコンテキストを
Binding オブジェクトで返します。

//emlist[例][ruby]{
d
ef fred(param)
proc
{}
end

sample_proc = fred(99)
eval("param", sample_proc.binding) # => 99
//}...

Proc#yield(*arg) -> () (24236.0)

手続きオブジェクトを実行してその結果を返します。

...しくは Proc#lambda? を参照してください。

「===」は when の所に手続きを渡せるようにするためのものです。

//emlist[例][ruby]{
d
ef sign(n)
case n
when lambda{|n| n > 0} then 1
when lambda{|n| n < 0} then -1
else 0
end
end

p sign(-4) #=> -1
p sign(0)...
...す。

//emlist[例][ruby]{
fib = lambda{|n|
case n
when 0 then 0
when 1 then 1
else
fib.(n - 2) + fib.(n - 1)
end
}
fib.(10) # => 55
//}



@param arg 手続きオブジェクトに与える引数を指定します。

@raise LocalJumpError Procを生成したメソッドからリタ...

絞り込み条件を変える

Proc#parameters(lambda: nil) -> [object] (21240.0)

Proc オブジェクトの引数の情報を返します。

...Proc オブジェクトの引数の情報を返します。

Proc
オブジェクトが引数を取らなければ空の配列を返します。引数を取る場合は、配列の配列を返し、
各配列の要素は引数の種類に対応した以下のような Symbol と、引数名を表す...
...& で指定されたブロック引数

@param lambda true なら lambda として扱ったとき、false なら lambda ではない Proc として
扱ったときの引数の情報を返します。

//emlist[例][ruby]{
prc = lambda{|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}
p...
...bda: の例][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...

shell/command-processor (18000.0)

Shell で使用可能なコマンドの大半を定義するライブラリです。

Shell で使用可能なコマンドの大半を定義するライブラリです。

Process::CLOCK_PROCESS_CPUTIME_ID -> Integer | Symbol (15300.0)

Process.#clock_gettime で使われます。

...
Proc
ess.#clock_gettime で使われます。

システムによっては :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID です。
システムによっては定義されていません。...

Hash#default_proc -> Proc | nil (12436.0)

ハッシュのデフォルト値を返す Proc オブジェクトを返します。 ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。

... Proc オブジェクトを返します。
ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。

//emlist[例][ruby]{
h = Hash.new {|hash, key| "The #{key} not exist in #{hash.inspect}"}
p h.default #=> nil
p block = h.default_proc #=> #<...
...Proc:0x0x401a9ff4>
p block.call({},:foo) #=> "The foo not exist in {}"

h = Hash.new("default")
p h.default #=> "default"
p h.default_proc #=> nil
//}

@see Hash#default...

Shell#command_processor -> Shell::CommandProcessor (12400.0)

@todo

...@todo...

絞り込み条件を変える

Tracer.display_process_id -> bool (12300.0)

真ならば、プロセス ID を表示します。 デフォルトは、偽です。

...真ならば、プロセス ID を表示します。
デフォルトは、偽です。...

Tracer.display_process_id? -> bool (12300.0)

真ならば、プロセス ID を表示します。 デフォルトは、偽です。

...真ならば、プロセス ID を表示します。
デフォルトは、偽です。...
<< 1 2 3 ... > >>