るりまサーチ

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

別のキーワード

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

モジュール

キーワード

検索結果

<< 1 2 3 ... > >>

Proc (44216.0)

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

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

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

Proc
がローカル変数のスコープ...
...を保持していることは以下の例で
変数 var を参照できていることからわかります。

//emlist[例][ruby]{
var = 1
$foo = Proc.new { var }
var = 2

def foo
$foo.call
end

p foo # => 2
//}

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

手続きオブ...
...に振る舞う
ことを意図されているため、例外 LocalJumpError は発生しません。

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

foo.call
# => in `call': return from proc-closure (LocalJumpError)
//}

以下の表は、手続きオブジェクトの実行を上の例と...

Proc#to_proc -> self (36313.0)

self を返します。

...self を返します。

//emlist[例][ruby]{
pr = proc {}
p pr == pr.to_proc # => true
//}...

Shell::ProcessController.active_process_controllers -> () (27400.0)

@todo

@todo

Shell::ProcessController.process_controllers_exclusive -> () (27400.0)

@todo

@todo

Shell::ProcessController.wait_to_finish_all_process_controllers -> () (27400.0)

@todo

@todo

絞り込み条件を変える

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.

...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...
...ormal 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.

This should only be used for procs that delegate keyword...
...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#curry -> Proc (27360.0)

Procをカリー化します

...Procをカリー化します

カリー化したProcはいくつかの引数をとります。十分な数の引数が与えられると、元のProcに引数を渡し
て実行し、結果を返します。引数の個数が足りないときは、部分適用したカリー化Procを返します...
...@param arity 引数の個数を指定します
@return カリー化したProcオブジェクトを返します

//emlist[例][ruby]{
b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> 6
p b.curry(5)[1][2][3][4][5] #=> 6
p b.curry(5)[...
...1, 2][3, 4][5] #=> 6
p b.curry(1)[1] #=> 1

b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.sum }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> 10
p b.curry(5)[1][2][3][4][5] #=> 15
p b.curry(5)[1, 2][3, 4][5] #=> 15
p b.curry(1)[1] #=> 1

b =...

Proc#curry(arity) -> Proc (27360.0)

Procをカリー化します

...Procをカリー化します

カリー化したProcはいくつかの引数をとります。十分な数の引数が与えられると、元のProcに引数を渡し
て実行し、結果を返します。引数の個数が足りないときは、部分適用したカリー化Procを返します...
...@param arity 引数の個数を指定します
@return カリー化したProcオブジェクトを返します

//emlist[例][ruby]{
b = proc {|x, y, z| (x||0) + (y||0) + (z||0) }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> 6
p b.curry(5)[1][2][3][4][5] #=> 6
p b.curry(5)[...
...1, 2][3, 4][5] #=> 6
p b.curry(1)[1] #=> 1

b = proc {|x, y, z, *w| (x||0) + (y||0) + (z||0) + w.sum }
p b.curry[1][2][3] #=> 6
p b.curry[1, 2][3, 4] #=> 10
p b.curry(5)[1][2][3][4][5] #=> 15
p b.curry(5)[1, 2][3, 4][5] #=> 15
p b.curry(1)[1] #=> 1

b =...

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

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

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

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

: :req
必須の引数
: :opt
デフォルト値が指定されたオプショナルな引数
: :rest
* で指定された残りすべての引数
: :keyreq
必須のキーワード引数
: :key
デフォルト値が指定されたオプショナルなキーワード引数
: :keyrest
**...
...@param lambda true なら lambda として扱ったとき、false なら lambda ではない Proc として
扱ったときの引数の情報を返します。

//emlist[例][ruby]{
prc = lambda{|x, y=42, *other, k_x:, k_y: 42, **k_other, &b|}
prc.parameters #=> x], [:opt, :y], [:rest...

Proc#arity -> Integer (27228.0)

Proc オブジェクトが受け付ける引数の数を返します。

...
Proc
オブジェクトが受け付ける引数の数を返します。

ただし、可変長引数を受け付ける場合、負の整数

-
(必要とされる引数の数 + 1)

を返します。

//emlist[例][ruby]{
lambda{ }.arity # => 0
lambda{|| }.arity # => 0
lambd...
...a{|x| }.arity # => 1
lambda{|*x| }.arity # => -1
lambda{|x, y| }.arity # => 2
lambda{|x, *y| }.arity # => -2
lambda{|(x, y)| }.arity # => 1
lambda{|(x, y), z|}.arity # => 2
//}...

絞り込み条件を変える

Proc#source_location -> [String, Integer] | nil (27224.0)

ソースコードのファイル名と行番号を配列で返します。

... ruby で定義されていない(つまりネイティブ
である)場合は nil を返します。


//emlist[例][ruby]{
# /path/to/target.rb を実行
proc
{}.source_location # => ["/path/to/target.rb", 1]
proc
{}.source_location # => ["/path/to/target.rb", 2]
(eval "proc...
...{}").source_location # => ["(eval)", 1]
method(:p).to_proc.source_location # => nil
//}

@see Method#source_location...

Proc#parameters -> [object] (27222.0)

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

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

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

: :req
必須の引数
: :opt
デフォルト値が指定されたオプショナルな引数
: :rest
* で指定された残りすべての引数
: :keyreq
必須のキーワード引数
: :key
デフォルト値が指定されたオプショナルなキーワード引数
: :keyrest
**...
...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...
<< 1 2 3 ... > >>