It all comes down to a matter of preference, I suppose.

On Mon, May 18, 2009 at 9:12 AM, Edward Heil <[email protected]> wrote:
> I think you've got to distinguish newlines from other whitespace.
>
> In the ruby I have handy (1.8.6), you can put whitespace all over the place
> before and after the dot.  You can put a newline after a dot; the dot tells
> ruby there's more to come on the next line.  But if you put the newline
> before the dot, Ruby will think the previous line is complete, and won't
> know what to do with the dot when it appears on the next line
>
> "foo".
> split("")
>
> is fine;
>
> "foo"
> .split("")
>
> is not.
>
> The same is true of other operators:
>
> 3 +
> 3
>
> works fine;
>
> 3
> + 3
>
> doesn't work.
>
>
>
>
> On May 18, 2009, at 12:19 AM, Roy Wright wrote:
>
>> Sarah Allen wrote:
>>>
>>> So, in Ruby 2.0, the dot works like any other operator and can have
>>> whitespace/newlines before or after, but right now Ruby arbitrarily
>>> (because it wants to conform to English sentences?) does not allow
>>> whitespace before it, but does allow whitespace after?
>>>
>>> Have I got that right?
>>>
>>> On May 17, 2009, at 11:45 AM, Devyn Cairns wrote:
>>>
>>>> Yeah, I agree, I don't usually use spaces for that.
>>>>
>>>> I can't wait for Ruby 2.0 to be stable, 'cause then I can do this:
>>>>
>>>> "hello world"
>>>> .sub('he', 'goo')
>>>> .sub('l', 'd')
>>>> .sub('lo', 'bye')
>>>> #=> "goodbye world"
>>>>
>>>> with long chains of message passing.
>>>>
>>
>> That's what it looks like...
>>
>> r...@royw-gentoo ~ $ ruby18 --version
>> ruby 1.8.7 (2009-04-08 patchlevel 160) [i686-linux]
>> r...@royw-gentoo ~ $ ruby19 --version
>> ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
>> r...@royw-gentoo ~ $ cat t.rb
>> #!/usr/bin/env ruby
>>
>> puts 'hello world'
>>    .sub('he', 'goo')
>>    . sub('l', 'd')
>>    .
>>    sub('lo', 'bye')
>> r...@royw-gentoo ~ $ ruby18 t.rb
>> t.rb:4: syntax error, unexpected '.', expecting $end
>>    .sub('he', 'goo')
>>     ^
>> r...@royw-gentoo ~ $ ruby19 t.rb
>> goodbye world
>>
>>
>
>



-- 
    ~devyn

Reply via email to