.serialhex .. wrote in post #1021524:
>
> ```
> "foo".to_a().length()
> # vs
> "foo".to_a.length
> ```
I agree that having to write empty paranthesises is not all that great
and that is not something I would do in Ruby. I mean that I like to
write them in places like:
Dir.glob("*txt")
array.delete_at(1)
To my knowledge, there is no technical difference for executing code
between when it has parentheses and when it lacks them, as long as you
don't run into precedence problems. For instance, these two lines of
code have the same effects when executed:
Dir.glob("*txt")
Dir.glob "*txt"
These two, however, do not:
Dir.glob("txt").map {|x| x.sub(/foo/, 'bar') }
Dir.glob "txt".map {|x| x.sub(/foo/, 'bar') }
Similarly, these are equivalent:
hash.delete(1)
hash.delete 1
These two, on the other hand, are not:
hash.delete 1.to_sym
hash.delete(1).to_sym
These have the same effect, of course:
hash.delete 1.to_sym
hash.delete(1.to_sym)
I find the first of the two more immediately readable than the second. I
suppose your mileage may vary.
in other words, after methods and the like.
You seem unaware that to_a and length, in the above example provided by
hex, *are* methods.
···
On Tue, Sep 13, 2011 at 05:50:35AM +0900, Vladimir Van Bauenhoffer wrote:
--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]