James Edward Gray II wrote: >>> def thisMethodName >>> caller[0] =~ /in `([^']+)'/ ? $1 : '(anonymous)'; >>> end >> >> I understand the concept. >> >> is there possibly a more direct solution available, with cleaner code >> and a stable/higher execution speed? > > Have you measured it and proven it too slow? Remember, premature > optimization is the root of all evil in programming. ;) > > I'm not sure what you consider "clean", but getting rid of the ternary > operator may make it a little more readable: > > if caller[0] =~ /in `([^']+)'/ then $1 else '(anonymous)' end Hm, perhaps even this: caller.first[/in `(.+?)'/, 1] || "(anonymous") Don't know if you'd prefer that, though.