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.
On Sat, May 16, 2009 at 10:08 PM, Roy Wright <[email protected]> wrote:
> In ruby, the '.' is an operator that says send the following message to
> the preceding object. Because it is an operator it my have optionally
> have whitespace around it just like other operators. Traditionally
> whitespace is not used around it to visually enhance the connection
> between the object and the message.
>
>
> Emmanuel Pirsch wrote:
>> You can explain that it is just like in English. You don't put a space
>> before the dot at the end of a sentence, but you put one after.
>>
>>
>> You can say that this is the same rule for the Ruby language, but that it
>> does allow you not put one after.
>>
>>
>> On Sat, May 16, 2009 at 8:09 PM, Sarah Allen <[email protected]> wrote:
>>
>>> interesting. This is more a Ruby question than a Shoes question, but how
>>> would one explain (to a young novice programmer) why it is ok to have a
>>> space after and not before? Is it just kind of arbitrary, or is there some
>>> rationale? I must admit, that I haven't really explored the rules around
>>> whitespace for Ruby, since I'm relatively new to it myself. They may never
>>> ask... I'm just curious.
>>>
>>> Sarah
>>>
>
--
~devyn