On Wed, 27 Jul 2011 at 18:30:57, in comp.lang.javascript, pedz wrote:
>Google tells me to "Please try again"... I apologize if this is a
>duplicate message.
>
>Is there a way to implement the equivalent of the "missing_method"
>method in Ruby? If you call foo.whatever(args) in Ruby and the
>whatever method is not defined, then it will call the missing_method
>method if it is defined passing it "whatever" along with the args.
>
>I realize that I can implement this with defining a function "blah" and
>then just do foo.blah("whatever", args) but the "blah" is distracting.
>It is much clearer to call foo.whatever(args). Is there a way to do
>that in Javascript?
>
>Note, that usually the "whatever" is not a single or even a few
>possible names but is usually a pattern or a large set such that
>defining all of them is either not possible until run time or
>impractical.
It sounds as though you're trying to use properties for something they
aren't good for. Have you considered other ways? E.g holding names in a
sorted array.
John
--
John Harris
|