Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby 3.0 から lambda(&block) が非推奨になる説明を追加 #2488

Merged
merged 1 commit into from
Mar 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion refm/api/src/_builtin/functions
Original file line number Diff line number Diff line change
Expand Up @@ -2451,15 +2451,31 @@ bind によらずに特定のオブジェクトのコンテキストで expr を

@raise ArgumentError スタック上にブロックがないのにブロックを省略した呼び出しを行ったときに発生します。
#@else

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

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

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

#@since 3.0.0
def foo &block
proc(&block)
end

it = foo{p 12}
it.call #=> 12
#@else
def foo &block
lambda(&block)
end

it = foo{p 12}
it.call #=> 12
#@end

@see [[c:Proc]],[[m:Proc.new]]

Expand Down