So where does precedence come in?
Maybe this will help (this is Hal Fulton's reply to me from about a month
ago(August 19, 2005) (on the similar question):
<quote>
Re: Newbie question
From: Hal Fulton <
[email protected]>
To: (e-mail address removed) (ruby-talk ML)
Date: Yesterday 11:13:45 pm (20050819)
Randy said:
I'm not clear on what binding tighter means, or to what--any further hints
appreciated.
=
What he means is, it's a matter of precedence.
Observe the examples:
=
puts %w{cat bat rat}.map { |w| w.capitalize }
puts %w{cat bat rat}.map do |w|
w.capitalize
end
=
They mean essentially the same as:
=
puts(%w{cat bat rat}.map { |w| w.capitalize })
puts(%w{cat bat rat}.map) do |w|
w.capitalize
end
=
In the second one, the map doesn't have a block associated with it --
the block is associated with the puts instead. The map with the
empty block effectively does nothing, and the puts never calls the
block given to it.
</quote>
Randy Kramer