From: "F. Senault" Date: 2009-01-29T06:02:45+09:00 Subject: Re: yield vs. return Le 28 janvier 2009 � 21:09, klochner a �crit : > I see a lot of ruby programmers doing the latter, but consider the > former to be more straightforward. There are a lot of cases where > yielding is more elegant than return, but I don't consider this to > be one of them. Anyone care to weigh in? Depends on what you do with it. I kinda like to use yield in "builder" statements where the code will we nested. For instance, something like (completely random example) : box.contents do |c| c.title = "Blah" c.font = "Courier" c.color = "Blue" c.para do |t| t.text = "This is blahblah" t.color = "Black" end end While you could do something like : c = box.contents c.title = "Blah" c.font = "Courier" c.color = "Blue" t = c.para t.text = "This is blahblah" t.color = "Black" (The code behind the 'para' method would probably just be 'yield @para' or 'yield Para.new(self)'.) The best (IMHO) is, of course, the freedom of : def funcfoo yield foo if block_given? foo end Where you can nest or assign. Fred -- Hey God, I really don't know what you mean (Nine Inch Nails, Seems like salvation comes only in our dreams Terrible Lie) I feel my hatred grow all the more extreme Hey God, can this world really be as sad as it fucking seems ?