From: "David A. Black" Date: 2004-12-05T05:37:26+09:00 Subject: Re: Using yield Hi -- On Sun, 5 Dec 2004, Brian [ISO-8859-15] Schr�der wrote: > On Sat, 4 Dec 2004 09:32:39 +0900 > "Joe Van Dyk" wrote: > > > I come from a heavy C++ background, discovered Ruby a few months ago and > > love it. > > > > I've found that using blocks is a very natural thing. However, I have not > > once used 'yield'. I'm sure that there are events when using yield would be > > helpful, but I have no clue when it would be appropriate to use. > > > > Thoughts? When do you use the 'yield' statement in code? > > > > Joe > > Yield is just a shortcut for block.call. > > If I am Lazy, and I don't need to pass the block further I use yield. But I > believe that normally using block.call is more explicit and therefore > preferable. 'yield' is equally explicit, and equally unambiguous. It tells you exactly as much as block.call does. I wouldn't worry about the laziness part of it; if you measure laziness by power per word of code, all Ruby programmers are already massively lazy :-) David -- David A. Black dblack@wobblini.net