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


Reply via email to