Dave Aronson wrote in post #1139187:
> On Fri, Mar 7, 2014 at 3:51 PM, Kape Kape <lists / ruby-forum.com> wrote:
>
>> When I do:
>>
>> ab4435 = MyClassFoo.new(blah)
>>
>> I want to get instance variable name 'ab4435' inside the class for use
>> in a methods.
> ...
>> What's the ruby way to do this?
>
> I think most of us would discourage such opaque trickery, but if you
> really Really REALLY need to, I think I would do something like:
>
> Declare a method that takes a parameter of a symbol, passes the symbol
> to the constructor, and uses the symbol to set an instance variable to
> the resulting value with instance_variable_set.  Then invoke it like
> "make_foo :bar" to do the equivalent of "bar = MyClassFoo.new(:bar,
> &any, Other::Arguments)".
>
> How?  Not gonna show you.  Too much ugly code out there already.
>
> -Dave

I really, really need to :-)

Let me ask a slightly different question.  Is the instance variable used 
by the caller of new() considered to be of type 'symbol'?

I'm not trying to do trickery, I simply want the object to be able later 
identify itself to the caller's environment with that name in a log 
file.

thanks,

Kape

-- 
Posted via http://www.ruby-forum.com/.