From: Robert Klemme Date: 2009-08-20T21:45:28+09:00 Subject: Re: #has_arguments? 2009/8/20 Brian Candler : > Robert Klemme wrote: >> As a side note: I see this sometimes >> >> def m(a = nil) >>   @a = a.nil? ? 123 : a >> end >> >> which is of course silly.  The same would be much better expressed as >> >> def m(a = 123) >>   @a = a >> end > > No, it's not the same. Can you explain what the differences are? > Consider: > >  def foo(a = nil) >    m(a) >  end > >  foo() I do not see the connection of this to what I posted. > It saves replicating your default values all over the place, which isn't > very DRY. I don't see how this makes me replicate my default values all over the place. My proposed solution just changes how a method internally works, there is _no_ effect on the interface. > Or you could more simply write > >  def m(a = nil) >    @a = a || 123 >  end I fail to see how this is simpler than def m(a = 123) @a = a end I'm in line with Rick: either _I_ must be missing something - or _you_. :-) Cheers robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/