0

Anyone knows if there is similar concept in other popular language compared to symbol literal in Ruby? Can I considered it just as an "Interned String"?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
user705414
  • 20,472
  • 39
  • 112
  • 155

2 Answers2

0

Yes, symbols (sometimes referred to as atoms in other languages) can be considered interned strings.

There's a ton of information on Ruby symbols here: Question - Understanding Symbols In Ruby

And, an afterthought, this question lists many examples of similar concepts in a couple languages:

Lisp and Erlang Atoms, Ruby and Scheme Symbols. How useful are they?

Community
  • 1
  • 1
Adam Eberlin
  • 14,005
  • 5
  • 37
  • 49
0

Anyone knows if there is similar concept in other popular language compared to symbol literal in Ruby?

Sure, symbols in Ruby come from symbols in Smalltalk, which in turn gets them from Lisp. Scala also has symbols, and Erlang's atoms are similar. Erlang probably got them from Prolog.

Can I considered it just as an "Interned String"?

You can consider it all sorts of things, but symbols are symbols. They aren't immutable strings or interned strings or whatever ... they are just symbols.

Jörg W Mittag
  • 363,080
  • 75
  • 446
  • 653
  • What's a good resource for learning what languages influenced Ruby and how they influenced it? – Andrew Grimm Oct 10 '11 at 01:25
  • Not sure. I don't think there *is* such a resource, but matz talks about it all the time in his conference talks and also in discussions on ruby-talk and ruby-core (and ruby-dev, I presume, but unfortunately, I don't understand Japanese). – Jörg W Mittag Oct 10 '11 at 07:50