9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rubyのlambdaリテラル

Last updated at Posted at 2012-02-12

矢じるしと引数リストのカッコがくっついてないとエラーになるよ

sytanx-error.rb
-> (x) { x+1 }
irb
SyntaxError: (irb):7: syntax error, unexpected tLPAREN_ARG, expecting keyword_do_LAMBDA or tLAMBEG
-> (x) { x+1 }
success.rb
->(x) { x+1 }

ちなみにカッコなしだと

success.rb
-> x { x+1 }
->x { x+1 }

どちらも関数をつくってくれます

9
9
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?