From: "F. Senault" Date: 2009-05-08T18:55:10+09:00 Subject: Re: Understanding { } and block_given Le 08 mai � 11:42, Srijayanth Sridhar a �crit : > [Note: parts of this message were removed to make it a legal post.] > > This is definitely not a block_given thing. It's an operator precedence thing. {} binds at a higher precedence than do/end, meaning that, in the absence of parentheses, in one case, it's the first function that takes the block and in the other, it's the second one. For instance : >> def test ; (block_given? ? 'block' : 'no block') ; end => nil >> puts test do end no block => nil >> puts test { } block In the first case, it's puts who gets the block (and discards it). In the second case, it's my function. Compare to : >> puts(test) do end no block => nil >> puts(test) {} no block => nil >> puts(test do end) block => nil >> puts(test {}) block Fred -- Just a reflection Just a glimpse Just a little reminder Of all the what abouts And all the might have Could have beens Another day Some other way But not another reason to continue And now you're one of us The wretched (Nine Inch Nails, The Wretched)