From: Nikolai Weibull Date: 2011-10-14T23:05:59+09:00 Subject: Re: What’s the best way of checking if an argument has been given or not? On Fri, Oct 14, 2011 at 15:51, Chris Hulan wrote: > You could do it as a wrapper: > > def foo_argchek *args >  if args.len == 0 >    "no args given" >  else >    real_foo(*args) >  end > end > > def real_foo(arg1, arg2) >  #do stuff > end How is this a solution (to anything)? One can, of course, use define_method (in 1.9), but it’s not ideal, as you can’t pass a block to A#a in that case. class A missing = Object.new define_method :a do |b = missing| if b == missing puts 'no argument given' else puts b end end end A.new.a A.new.a 1