From: Robert Klemme Date: 2011-04-21T20:18:03+09:00 Subject: Re: To Yield or Not to Yield: An Inferable Question On Thu, Apr 21, 2011 at 11:47 AM, Brian Candler wrote: > You are of course right in your analysis. > > My point is more that using "block_given?" in itself is API smell. It > means you have one method which can be called in two different ways, > with two different behaviours. The standard and core libraries are full of those (File.open, Enumerable methods...). > The other main example in the core library (1.8.7+) is methods like > 'each' which return an Enumerator if you don't pass a block. I don't > like that either. I find that utterly convenient. For generating a series of values I often use something like 17.times.map { ... } 42.times.to_a I find that very elegant. Brian, we are (or rather: Ruby is) not loosing you, are we? That would be sad. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/