From: Joel VanderWerf Date: 2006-10-27T08:05:19+09:00 Subject: Re: Pass block instead of here document? Rick DeNatale wrote: > On 10/26/06, Joel VanderWerf wrote: >> Rick DeNatale wrote: > >> > Of course this relies on UDPSocket::open returning the new socket >> > rather than something else. >> >> UDPSocket.open is the same as UDPSocket.new, which returns the new >> socket, as is standard for all #new methods. >> >> Actually, UDPSocket *does* take a block, so you don't need this >> construct here. It's for those cases (getting rarer and rarer as ruby >> libs evolve) where someone defines an #initialize method that does not >> take a block (or takes a block but does not yield the object to it). > > Or does something else with the block like > > Hash::new > > which captures a block if given and uses it to handle requests for > missing keys. Right. I shouldn't have suggested that all #initialize methods should yield the object for further configuration, since there are plenty of other legitimate uses for blocks, such as this one. -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407