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?
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
In Ruby, indentation per se is not relevant, although the location of linebreaks and other whitespace may cause ambiguity for the parser or cause it to consider certain things as separate expressions when you didn't mean for them to be. Here-documents and multi-line strings are also areas where indentation will matter.
In all cases, the real question is "what does the parser see?" In your example, it should be functionally equivalent to the properly-indented code. However, if you really want to know what's going on under the hood, take a look at Ruby's Ripper module to see how your code is actually being parsed.
Yes, it would work. Ruby only looks for the line breaks.
But since code readability is also very important, I'd say you should take care of whitespace if only for that sake.