How to name a variable after another variable's value?

Thanks all! Lots of good ideas!



-----Original Message-----
From: Tom Sawyer []
Sent: Thursday, July 18, 2002 5:05 AM
Subject: Re: How to name a variable after another variable’s value?

try something like:

greeting_no = “2”
attr “sp#{greeting_no}_greeting”.intern

and then you can do:



On Thu, 2002-07-18 at 00:37, Kurt Euler wrote:


Is there a way to name a variable partly after the value of some other variable:

I tried to do something like this:

greeting_no = “2”
sp#{greeting_no}_greeting = ‘Hello’

…with the idea of making 2nd line equivalent to writing:

sp2_greeting = “Hello”

…but this didn’t work.




(") dobee dobee do…
^ ^