Hatena::ブログ(Diary)

わからん

2011.01.30

[] Range#step.to_a と * のメモ

arr = *(1..10).step(3)          # => [1, 4, 7, 10]
arr = (1..10).step(3).to_a      # => [1, 4, 7, 10]
(1..10).step(3).to_a            # => [1, 4, 7, 10]
*(1..10).step(3)                # => 
# ~> -:4: syntax error, unexpected ')', expecting tCOLON2 or '[' or '.'
# ~> ...(1..10).step(3)               );$stderr.puts("!XMP1296330364...
# ~> ...                               ^
# ~> -:8: syntax error, unexpected $end, expecting ')'

はてなユーザーのみコメントできます。はてなへログインもしくは新規登録をおこなってください。

Google