"Makhno" <mak / imakhno.freeserve.co.uk> writes:

> I was wondering if it possible to obtain a reference to a function before it
> has been
> 'def'ined?

Sort of...

The reference to a function is by name, not by function pointer, so
you can use the name before the function exists:

   fn = case ARGV[0]
        when "clear"
             :doClear
        when "reset"
             :doReset
        else
             :doError
        end


 However the function must be defined before you can call it:

#    self.method(fn).call    # this would be an error

    def doClear
      puts "Clear"
    end
    def doReset
      puts "Reset"
    end
    def doError
      puts "Error"
    end

    self.method(fn).call     # This is OK



Regards



Dave