D
dblack
Hi --
The intent is very clear, I think. I just don't like the construct
![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I think my example, in (say) TestUnit, would be more like:
assert_equal(y,x)
But as I said, the magic dot example was made up, so I can't really
push the point of what it would be equal to in other terms.
I can't really comment without hooking my eyes up to a machine and
seeing where they go
But there's no necessity to backtrack once
you've seen x.each {|an_x|, from the point of view of understanding
the code. Mind you, the magic dot doesn't require backtracking
either.
David
--
David A. Black | (e-mail address removed)
Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org
This would be readable assuming that "should" on x meant something. If I
saw this I'd guess its like "assert".
But, assuming that your list of words DID mean something, then it has to
be more readable to newcomers (and yourself in 12 mths time) than the
possible equivalent:
The intent is very clear, I think. I just don't like the construct
x.each {|an_x| assert_equal y, x}
or to rephrase the example, perhaps:
x.should {|an_x| an_x.be :equal, :to, y}
I think my example, in (say) TestUnit, would be more like:
assert_equal(y,x)
But as I said, the magic dot example was made up, so I can't really
push the point of what it would be equal to in other terms.
The magic dot gives you left-to-right readability, whereas the above
makes you figure out whats happening in the closure first, then go back
to the x.each part to see where an_x comes from.
I can't really comment without hooking my eyes up to a machine and
seeing where they go
you've seen x.each {|an_x|, from the point of view of understanding
the code. Mind you, the magic dot doesn't require backtracking
either.
David
--
David A. Black | (e-mail address removed)
Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com | [4] http://www.rubycentral.org