るりまサーチ

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

別のキーワード

  1. _builtin new
  2. _builtin inspect
  3. _builtin []
  4. _builtin to_s
  5. _builtin each

種類

モジュール

キーワード

検索結果

Kernel.#lambda { ... } -> Proc (26241.0)

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

...します。


また、lambda に & 引数を渡すのは推奨されません。& 引数ではなくてブロック記法で記述する必要があります。

& 引数を渡した lambda は Warning[:deprecated] = true のときに警告メッセージ
「warning: lambda without a literal block...
...is deprecated; use the proc without lambda instead」
を出力します。

@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

===[a:sh...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...
...is deprecated; use the proc without lambda instead」
を出力します。

@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
proc(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

===[a:shou...

Kernel.#lambda -> Proc (26224.0)

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

Kernel.#lambda { ... } -> Proc (26224.0)

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

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

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

...します。


また、lambda に & 引数を渡すのは推奨されません。& 引数ではなくてブロック記法で記述する必要があります。

& 引数を渡した lambda は Warning[:deprecated] = true のときに警告メッセージ
「warning: lambda without a literal block...
...is deprecated; use the proc without lambda instead」
を出力します。

@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

===[a:sh...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...
...is deprecated; use the proc without lambda instead」
を出力します。

@raise ArgumentError ブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
proc(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

===[a:shou...

Kernel.#proc -> Proc (11124.0)

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

絞り込み条件を変える

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

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

Kernel.#proc -> Proc (11123.0)

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

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

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

...のメソッドで指定されたブロック
を得たい場合は明示的に & 引数でうけるべきです。

ブロックを指定しない lambda は Ruby 2.6 までは警告メッセージ
「warning: tried to create Proc object without a block」
が出力され、Ruby 2.7 では
Argument...
...にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。

//emlist[例][ruby]{
def foo &block
lambda
(&block)
end

it = foo{p 12}
it.call #=> 12
//}

@see Proc,Proc.new

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

手続きオブ...
...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...

Proc (8110.0)

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

...す。

//emlist[問題なし][ruby]{
(1..5).each { break }
//}

//emlist[LocalJumpError が発生します。][ruby]{
pr = Proc.new { break }
(1..5).each(&pr)
//}

===[a:lambda_proc] lambda と proc と Proc.new とイテレータの違い

Kernel.#lambda と Proc.new はどちらも Proc クラス...
...続きオブジェクト)を生成しますが、
生成された手続きオブジェクトはいくつかの場面で挙動が異なります。 lambda の生成する手続きオブジェクトのほうが
よりメソッドに近い働きをするように設計されています。

Kernel.#pro...
...続きオブジェクト化したブロックは、Proc.new で生成されたそれと
同じように振る舞います。

==== 引数の扱い

lambda
のほうがより厳密です。引数の数が違っていると(メソッドのように)エラーになります。
Proc.new は引数を...