[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: does ":" have an anolog in another language?

Charles Hoffman

7/28/2006 9:41:00 PM


-------------- Original message ----------------------
From: dblack@wobblini.net
> Ruby symbols aren't exactly used as variable names, though. If you
> assign to a variable:
>
> a = 1
>
> then Ruby creates and stores an :a symbol. But if you use the symbol
> :a, like this:
>
> b = :a
>
> there's no direct semantic connection to your variable called 'a'.

Well, that just makes it even *more* like Lisp than I was thinking. It hadn't occurred to me
that Ruby creates a symbol for a variable. But I guess it makes sense given some code I've seen that uses symbols to name methods and attributes and the like. assigning b = :a is like doing (setf b 'a) in Lisp, b contains a symbol, not 1 or a reference to the variable a itself or anything like that. What I wonder then, is what happens in Ruby if you were to then call eval(b) ? I haven't tried it.

--ch--

2 Answers

Kevin Clark

7/28/2006 9:47:00 PM

0

Ike, see:

http://gl.../articles/2005/08/19/understanding-ru...

for my take on symbols.

--
Kevin Clark
http://gl...

dblack

7/28/2006 9:48:00 PM

0