From: Phlip Date: 2007-08-07T00:39:51+09:00 Subject: Re: yield or call? Pit Capitain wrote: > > When writing API-style code, I always start with &block because it's only a > > matter of time before I refactor the code and start passing that &block into > > a helper method. > > Phlip, you can do the equivalent with yield: > > def x(&b); xx(&b); end > def xx(&b); b.call; end > > vs. > > def y; yy { yield }; end > def yy; yield; end > > Also in this case the yield version is much faster. What if the block were optional? (I forgot to mention that's typical of API-style code...) -- Phlip http://www.oreilly.com/catalog/9780596510657/ ^ assert_xpath http://tinyurl.com/yrc77g <-- assert_latest Model