Kape Kape wrote in post #1139185:

> I want to get instance variable name 'ab4435' inside the class for use
> in a methods.


You can this with binding() object (ie. ruby Api: Binding
encapsulate the execution context at some particular place
in the code and retain this context for future use)

============
def ca(bind,name)
   c=(eval(name,bind)+1 rescue "unknown")
   puts "in call, #{name}=#{eval(name,bind)}"
   binding()
end


b=rand 1..111
p b
a=2

a= ca(binding(),"a")
ca(binding(),"b")
ca(binding(),"a")
ca(a,"c")
===========
>ruby a.rb
17
in call, a=2
in call, b=17
in call, a=#<Binding:0x26574f0>
in call, c=3

> I do this in itcl using uplevel by peeking at the calling stack frame

I am not sure that work in tcl :
> set a [doit ]

'a' is unknown at calling time of 'doit'

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