From: Hugh Sasse Staff Elec Eng Date: 2003-03-18T04:19:36+09:00 Subject: Re: Ruby Idiom: method with/without block On Tue, 18 Mar 2003, Robert wrote: [...] > with and without a block. When used with a block, the resource deallocator > ("close") must not be called, because that is done after the block exits via > "ensure". > > Now, to me this seems like mixing different behaviors in a single method. > Having methods that do different things depending on the argument list is > often regarded bad OO. I'm interested to hear why this approach was taken. Obviously I can't say *why" it was done. But it feels OK to me because the block form effectively makes the method a control structure, like while or if. They just change how your code behaves, one doesn't really think of passing in the code to while or if. Of course if one passed in a Proc.new {|x| ... }, that would feel different. Hugh > >