From: Daniel Schierbeck Date: 2006-07-09T04:30:06+09:00 Subject: Re: Sweet Lord! Phil Tomson wrote: > On 7/8/06, William James wrote: >> Daniel Schierbeck wrote: >> > Why haven't I thought of this before? >> > >> > class Terminal >> > include Enumerable >> > >> > def each(&block) >> > while input = gets >> > block.call(input.chomp) >> > end >> > end >> >> def each >> while input = gets >> yield input.chomp >> end >> end > > Equivilent code, actually. It's a case of "you say tomaTOE I say tomAHto" Actually, the `yield' version is significantly faster. When using the `&block' syntax, a Proc object is created for each iteration. From what I've gathered, that doesn't happen when using `yield'. Cheers, Daniel