Re: difference between :label and variable

Heng Li <[email protected]> Thu, 31 Oct 2019 20:00:29 -0700
Newsgroups gmane.comp.lang.ruby.general
Message-ID <CAKtyc31A+O6tqHGLGtajbnn-pP7=Q-eLKZyAVsLn-5BYDdr6fQ@mail.gmail.com>
Using ‘:label ’It’s more memory efficient.
For example, lets say you define a variable  a=5  and symbol :b=5
Then you examine their object_id by type
a.object_id and :b.object_id .
Now you change you a= 6 :b=6
Then you will see :b still has same object_id. But the object_id of the
variable ‘a’is not the same.
If you don’t know what object_id is you can do a quick google search for
the term. Hope this helps.

On Thu, Oct 31, 2019 at 5:57 PM Maggie Q Roth <[email protected]> wrote:

> dear members,
>
> what's the difference between :label and variable?
> I saw many hashes use :label as key, which has advantages than variable
> keys?
>
> Thank you.
> Maggie
>
> Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
>


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>