Do I need to indent my code in Ruby?

后端 未结 3 973
被撕碎了的回忆
被撕碎了的回忆 2021-01-07 22:32

You would think that this would be an easy question, but I can\'t find the answer anywhere. >_<

Will Ruby throw syntax errors if my code is indented incorrectly?

3条回答
  •  没有蜡笔的小新
    2021-01-07 22:53

    Ruby is not whitespace sensitive. Your code, although not pretty, will work.

    However: http://www.ruby-forum.com/topic/56039

    irb(main):001:0> a = ( 4 + 5 )
    => 9
    irb(main):002:0> a = ( 4
    irb(main):003:1>       + 5 )
    => 5
    irb(main):004:0> a = ( 4 +
    irb(main):005:1*       5 )
    => 9
    

提交回复
热议问题