"Luigi Ballabio" <luigi.ballabio / fastwebnet.it> schrieb im Newsbeitrag news:pan.2003.06.24.14.18.21.963302 / fastwebnet.it... > Hi all, > having to design a usable environment for non > extremely-computer-literate users, I'd like them to fire > up irb with some default options via an alias and write: > > Foo> foo = 'life' > Foo> bar = 'the universe' > Foo> baz = 'everything' > Foo> calculate > ==> 42 > Foo> > > Here, the calculate() method would (in my dreams) inspect > the caller's environment, find out the values of foo, bar > and baz, and use them in its calculation. Of course, in > the real thing the parameters would be a few more, and > some of them could be omitted. Is there a decent way to > accomplish this? If you can guess the variable names you can do: b = eval 'x' A simple solution to your problem is to use instance variables like this: irb(main):001:0> @foo = 'life' "life" irb(main):002:0> @bar = 'the universe' "the universe" irb(main):003:0> @baz = 'everything' "everything" irb(main):004:0> irb(main):005:0* instance_variables ["@bar", "@foo", "@baz"] irb(main):006:0> instance_variables.map{|var| eval var} ["the universe", "life", "everything"] irb(main):007:0> Regards robert