james.d.masters
5/9/2007 6:16:00 PM
On May 9, 11:08 am, s...@seebs.net (Peter Seebach) wrote:
> In message <f12329bb77e7a3fa17dc936713d87...@ruby-forum.com>, anakintang writes:
>
> >How can I write "s = s1 + s2 + s3" in multiple lines like below:
> >s= s1
> > + s2
> > + s3
>
> You can't.
>
> You can do it differently, though:
>
> s = s1 +
> s2 +
> s3
>
> If you have an operator at the end of the line, needing operands, Ruby
> keeps reading.
>
> -s
You actually can with a trailing backslash:
% irb
irb(main):001:0> s1 = s2 = s3 = 1
=> 1
irb(main):002:0> s = s1 irb(main):003:0* + s2 irb(main):004:0* + s3
=> 3