るりまサーチ

最速Rubyリファレンスマニュアル検索!
292件ヒット [1-100件を表示] (0.028秒)

別のキーワード

  1. _builtin to_proc
  2. _builtin proc
  3. proc curry
  4. httpserver mount_proc
  5. readline completion_proc

検索結果

<< 1 2 3 > >>

Proc (38216.0)

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

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

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

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

def foo
$foo.call
end

p foo # => 2
//}

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

手続きオブジェクトを中断して、呼出し元(呼び出しブロックでは yield、それ以外では Proc#call)
へジャン...
...][ruby]{
def foo
f
= Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:block] Proc オブジェクトをブロック付きメソッド呼び出しに使う

ブロック付きメソッドに対して Proc オブジェク...

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

This should only be used for procs that d...
...backwards 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
fo...

Proc#curry -> Proc (21184.0)

Procをカリー化します

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

カリー化したProcはいくつかの引数をとります。十分な数の引数が与えられると、元のProcに引数を渡し
て実行し、結果を返します。引数の個数が足りないときは、部分適用したカリー化Procを返します...
...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,...
...[2][3] #=> 6
p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3)
p b.curry(5) #=> wrong number of arguments (given 5, expected 3)
p b.curry(1) #=> wrong number of arguments (given 1, expected 3)

b = lambda {|x, y, z, *w| (x||0)...

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

Procをカリー化します

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

カリー化したProcはいくつかの引数をとります。十分な数の引数が与えられると、元のProcに引数を渡し
て実行し、結果を返します。引数の個数が足りないときは、部分適用したカリー化Procを返します...
...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,...
...[2][3] #=> 6
p b.curry[1, 2][3, 4] #=> wrong number of arguments (given 4, expected 3)
p b.curry(5) #=> wrong number of arguments (given 5, expected 3)
p b.curry(1) #=> wrong number of arguments (given 1, expected 3)

b = lambda {|x, y, z, *w| (x||0)...

RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (18272.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。

@param proc...
... Procもしくはメソッドオブジェクトを指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を指定すると、 Node#token が利用...
...byVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SC...

絞り込み条件を変える

RubyVM::AbstractSyntaxTree.of(proc, keep_script_lines: false, error_tolerant: false, keep_tokens: false) -> RubyVM::AbstractSyntaxTree::Node (18272.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。

@param proc...
... Procもしくはメソッドオブジェクトを指定します。
@param keep_script_lines true を指定すると、 Node#script_lines でノードと関連づけられたソースコードのテキストを取得できます。
@param keep_tokens true を指定すると、 Node#token が利用...
...byVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

def hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SC...

RubyVM::AbstractSyntaxTree.of(proc) -> RubyVM::AbstractSyntaxTree::Node (18270.0)

引数 proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

... proc に渡したProcやメソッドオブジェクトの抽象構文木を返します。

このメソッドはProcやメソッドが定義されたファイルを読み込む必要があるため、
irbのようなファイルを介さない対話的環境では動作しません。

@param proc...
... Procもしくはメソッドオブジェクトを指定します。

//emlist[][ruby]{
pp RubyVM::AbstractSyntaxTree.of(proc {1 + 2})
# => (SCOPE@2:38-2:45
# tbl: []
# args: nil
# body:
# (OPCALL@2:39-2:44 (LIT@2:39-2:40 1) :+
# (LIST@2:43-2:44 (LIT@2:43-2:44 2) nil)))

d...
...ef hello
puts "hello, world"
end

pp RubyVM::AbstractSyntaxTree.of(method(:hello))
# => (SCOPE@5:0-7:3
# tbl: []
# args:
# (ARGS@5:9-5:9
# pre_num: 0
# pre_init: nil
# opt: nil
# first_post: nil
# post_num: 0
# post_init: nil
# rest: n...

RubyVM::InstructionSequence.of(body) -> RubyVM::InstructionSequence (18195.0)

引数 body で指定した Proc、Method オブジェクトを元に RubyVM::InstructionSequence オブジェクトを作成して返します。

... Proc、Method オブジェクトを元に
RubyVM::InstructionSequence オブジェクトを作成して返します。

@param body Proc、Method オブジェクトを指定します。

例1:irb で実行した場合

# proc
> p = proc { num = 1 + 2 }
> RubyVM::InstructionSequence.of(p)...
...onSequence.of(method(:foo))
> # => <RubyVM::InstructionSequence:foo@(irb)>

例2: RubyVM::InstructionSequence.compile_file を使用した場合

# /tmp/iseq_of.rb
def hello
puts "hello, world"
end

$a_global_proc = proc { str = 'a' + 'b' }

# irb
> require '/tmp/iseq_of.rb'

# h...
...ello メソッド
> RubyVM::InstructionSequence.of(method(:hello))
> # => #<RubyVM::InstructionSequence:0x007fb73d7cb1d0>

# グローバル proc
> RubyVM::InstructionSequence.of($a_global_proc)
> # => #<RubyVM::InstructionSequence:0x007fb73d7caf78>...

Profiler__::PROFILE_PROC -> Proc (15302.0)

内部で使用します。

内部で使用します。

Process::CLOCK_PROF -> Integer (9100.0)

Process.#clock_gettime で使われます。

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

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

絞り込み条件を変える

Process::RLIMIT_NOFILE -> Integer (9100.0)

リソースの種類がプロセスがオープンできるファイルの数であることを示す定数です。

...リソースの種類がプロセスがオープンできるファイルの数であることを示す定数です。

Proc
ess.#getrlimit、Process.#setrlimit で使われます。
システムによっては定義されていません。...

MiniTest::Assertions#assert_kind_of(klass, object, message) -> true (6131.0)

与えられたオブジェクトが与えられたクラスまたはそのサブクラスのインスタンス である場合、検査にパスしたことになります。

...@param message 検査に失敗した場合に表示するメッセージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。

@raise MiniTest::Assertion 与えられたオブジェクトが...
...与えられたクラスまたはそのサブクラスの
インスタンスではない場合に発生します。

@see Object#kind_of?, MiniTest::Assertions#assert_instance_of...

MiniTest::Assertions#assert_instance_of(klass, object, message = nil) -> true (6125.0)

与えられたオブジェクトが与えられたクラスの直接のインスタンスである場合、検査にパスしたことになります。

...@param message 検査に失敗した場合に表示するメッセージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。

@raise MiniTest::Assertion 与えられたオブジェクトが...
...与えられたクラスの直接のインスタンスでない
場合に発生します。

@see Module#===, MiniTest::Assertions#assert_kind_of...

Kernel.#proc -> Proc (3472.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...与えられたブロックから手続きオブジェクト (Proc のインスタンス)
を生成して返します。Proc.new に近い働きをします。

ブロックが指定されなければ、呼び出し元のメソッドで指定されたブロック
を手続きオブジェクトと...
...までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE = true のときには警...
...では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。


//emlist[例][ruby]{
def foo
f
= Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:block] Proc...

Kernel.#proc { ... } -> Proc (3472.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...与えられたブロックから手続きオブジェクト (Proc のインスタンス)
を生成して返します。Proc.new に近い働きをします。

ブロックが指定されなければ、呼び出し元のメソッドで指定されたブロック
を手続きオブジェクトと...
...までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE = true のときには警...
...では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。


//emlist[例][ruby]{
def foo
f
= Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:block] Proc...

絞り込み条件を変える

Kernel.#proc -> Proc (3471.0)

与えられたブロックから手続きオブジェクト (Proc のインスタンス) を生成して返します。Proc.new に近い働きをします。

...与えられたブロックから手続きオブジェクト (Proc のインスタンス)
を生成して返します。Proc.new に近い働きをします。

ブロックが指定されなければ、呼び出し元のメソッドで指定されたブロック
を手続きオブジェクトと...
...までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
ArgumentError (tried to create Proc object without a block)
が発生します。

ブロックを指定しない proc は、Ruby 2.7 では
$VERBOSE = true のときには警...
...では Proc#call)
へジャンプし値を返すには next を使います。break や return ではありません。


//emlist[例][ruby]{
def foo
f
= Proc.new{
next 1
2 # この行に到達することはない
}
end

p foo().call #=> 1
//}

===[a:block] Proc...
<< 1 2 3 > >>