MC logo

Line Breaking

  Ruby Example Code

<<Hashes lines.rb Basic I/O I>>
a = 10
b = a +
c = [ 5, 4, 
        10 ]
d = [ a ] \
        + c
print "#{a} #{b} [", c.join(" "), "] [", d.join(" "), "]\n";

See:Programming Ruby

Ruby generally uses line breaks instead of semicolons to separate statements. Lines can be continued by using a \ at the end, but this is rarely needed. If the line ends with pretty much anything that suggests there should be more, Ruby will continue on to the next line. This includes such things as ending with an operator, or inside parentheses or something else which needs to be closed.
<<Hashes Basic I/O I>>