You can put a space before and/or after the dot. But the standard way
to do it is no space unless you are putting the method on the next
line. It's entirely a matter or taste, but sticking to styles of coding
that other ppl use will make your code more read able to those people.
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]
<mailto:[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
On May 15, 2009, at 10:14 PM, Roy Wright wrote:
Hugh Sasse wrote:
On Fri, 15 May 2009, Sarah Allen wrote:
- Errors for which the error messages were hard to
figure out
Shoes. app � (note: they are trained to put a space
after the period) �also
Shoes . app
The first is acceptable ruby: I recall seeing lines split
after a '.'
on Ruby-Talk (possibly from the late Guy Decoux).
I point this out because it is an interesting failure mode
which
may tell us something useful.
I can verify this for Ruby 1.8.7's IRB
13:32:36$ irb
irb(main):001:0> (3 * 7). to_s
=> "21"
irb(main):002:0> (3 * 7).
irb(main):003:0* to_s
=> "21"
irb(main):004:0>
But I don't have a 1.9.1 on any machines yet, so can't
tell you if
that has changed.
royw-gentoo ~ # ruby --version
ruby 1.9.1p0 (2009-01-30 revision 21907) [i686-linux]
royw-gentoo ~ # irb --version
irb 0.9.5(05/04/13)
royw-gentoo ~ # irb
irb(main):001:0> (3 * 7).to_s
=> "21"
irb(main):002:0> (3 * 7). to_s
=> "21"
irb(main):003:0> (3 * 7) . to_s
=> "21"
irb(main):004:0> (3 * 7).
irb(main):005:0* to_s
=> "21"
HTH,
Roy
http://www.ultrasaurus.com