From: dblack@... Date: 2002-10-12T20:50:36+09:00 Subject: Re: Another take on ensuring right args to methods Hi -- On Mon, 7 Oct 2002, Massimiliano Mirra wrote: > On Sun, Oct 06, 2002 at 10:43:46PM +0900, dblack@candle.superlink.net wrote: > > Personally I like #can? but it doesn't help with the awkward two-headed > > "obj.meth if obj.can?(:meth)" idiom. > > I know, but I'm still convinced that you'd only want to do that when > calling meth on obj was totally optional to the logic, which happens > seldom (at least in my experience). Or if you're branching: if obj.respond_to?(x) obj.x elsif obj.respond_to?(y) obj.y ... end which is probably a sign of a design flaw... but the project that originally got me thinking about a lot of this stuff, a year or so ago, was one where I ended up doing something like the above (and not liking it :-) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav