Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Understanding Syntax Error on Ruby Blocks

Understanding Syntax Error on Ruby Blocks

Tetsuya Kaneko

April 16, 2019
Tweet

More Decks by Tetsuya Kaneko

Other Decks in Programming

Transcript

  1. Ruby 1.9.0-4 (ಈ͘) $ ruby -ve '1.upto 2 {|i| p

    i} ' ruby 1.9.0 (2008-08-26 revision 18849) [i386-darwin18.2.0 ] 1 2
  2. Ruby 2.3.3 (ಈ͔ͳ͍) $ ruby -ve '1.upto 2 {|i| p

    i} ' ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18 ] -e:1: syntax error, unexpected '{', expecting end-of-inpu t 1.upto 2 {|i| p i}
  3. Ruby 2.4.0 (ಈ͘) $ ruby -ve '1.upto 2 {|i| p

    i} ' ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin18 ] 1 2
  4. Ruby 2.4.1 (ಈ͘) $ ruby -ve '1.upto 2 {|i| p

    i} ' ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin18 ] 1 2
  5. Ruby 2.4.2 (ಈ͔ͳ͍) $ ruby -ve '1.upto 2 {|i| p

    i} ' ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-darwin18 ] -e:1: syntax error, unexpected '{', expecting end-of-inpu t 1.upto 2 {|i| p i}
  6. ྺ࢙ΛḪΔ͜ͱ10೥ • ΋ͱ͸1.9Ͱ࢓༷มߋͱͯ͠௥Ճ͞ΕɺΑΓ਌੾ʹϒϩοΫΛղ ऍ͢ΔΑ͏ͳ΋ͷͩͬͨ • ʮϓϩάϥϚ͸ a {|i| ...} ͸ϝιουݺͼग़͠ͱͯ͠ղऍ͢Δ͕ɺ

    2 {|i| …} ͸ϝιουݺͼग़͠ͱ͸ղऍ͠ͳ͍͸ͣͩʯ • ʮϦςϥϧͰ͋Δ͔ม਺Ͱ͋Δ͔ͰৼΔ෣͍͕ҟͳΔ͜ͱ͸ɺࠞ ཚΛট͘Մೳੑ͕͋Δʯ Bug #505: 1.upto 2 {|i| p i } - Ruby trunk - Ruby Issue Tracking System
  7. ٞ࿦ͷ຤ * parse.y (yylex): "1.upto 2 {|i| p i }"

    should be syntax error. · ruby/ruby@05edaf5
  8. ͦͷޙ΋ಈ͍ͨΓಈ͔ͳ͔ͬͨΓ • Bug #13547: [].delete 1 { 'NG' } -

    Ruby trunk - Ruby Issue Tracking System • Bug #14023: SyntaxError on array argument and block - Ruby trunk - Ruby Issue Tracking System