Ruby Basics : Symbol
In this article you will learn the concept of symbol and when it is used in Ruby programs.
The dove is a symbol. It represents peace. There is a one-to-one association between the symbol and what it represents.
The symbol identifier begins with a colon. In the IRB console, we can represent dove symbol like this:
> :dove => :dove
It is unique, as there is only one object corresponding to the dove symbol. We can verify it.
> :dove.object_id => 1175068 > :dove.object_id => 1175068 > :dove.object_id => 1175068 > :dove.object_id => 1175068
Regardless of how many times you call the object_id, the memory location of the object is the same.
In this article, you learned about symbol and how it is unique in a running program. Symbols are used as the arguments to methods and as name of methods.
Software Compatibility Best Practices
I spoke to some of the most talented and experienced software developers. I have created a guide that is filled with valuable insights and actionable ideas to boost developer productivity.
You will gain a better understanding of what's working well for other developers and how they address the software compatibility problems.