On Fri, Oct 14, 2011 at 15:51, Chris Hulan <chris.hulan / gmail.com> 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