From: ara.t.howard@... Date: 2006-07-13T23:26:34+09:00 Subject: Re: prototype design pattern On Thu, 13 Jul 2006 transfire@gmail.com wrote: > Why no go the extra step? > > DB = Prototype.new{ > host 'localhost' > port 4242 > > connect does{ 'do something' } > > inspect does{ [host, port].join ':' } > } > > T. easy enough, i'd simply make does() return a block extended with a marker: def does &b class << b def does() true end end b end then, later if b.respond_to? 'does' # defined a method else # attribute with proc value end otherwise i could tell the difference between foobar lambda{ 'plain ol block' } foobar does{ 'method body' } in any case, i'm unclear as to what connect does{ 'do something' } buys you over def connect() 'do something' end other than two chars. i admit it looks nice though... actually i guess the closure might make it nice since you could do a = 42 connect does{ p a } which you cannot with a normal method def. so - what's __your__ reasoning on this? cheers. -a -- suffering increases your inner strength. also, the wishing for suffering makes the suffering disappear. - h.h. the 14th dali lama