On Apr 15, 3:28 pm, "Robert Dober" <robert.do... / gmail.com> wrote:
>
> > > So you are proposing all undefined locals return nil too?  }}:-)
>
> > Perhaps Kernel.variable_missing?
> > Or I'm just crazy...
>
> I hope not ;), but I think this will enter in conflict with method_missing.
>
> Robert
>

I think it's not a preposterous (translation dictionaries are silly)
idea after all, if handled well. Say, method_missing would have more
precedence than variable_missing.

As for now, method missing is worth a try

def method_missing
  nil
end

foo
=> nil
x ||= 10
=> 10
x
=> 10

but this is obviously wicked. Specially with typos and lexical
mistakes. I think it's worse to get bad results from bad valued than
get an error and make things right instead.

Oh, and it doesn't handle constants.

FOO
=> NameError: uninitialized constant OK
        from (irb):32
        from :0