Symbol (Colon in Ruby)

Source: Internet
Author: User

Symbol: Denotes "First name", such as the name of the string, the name of the identifier.

How to create a Symbol object: precede a name or string with a colon

: Test: " Hello Ruby "

In Ruby, each object has a unique object identifier (Identifier), which can be used to get an identifier for an object using the Object_ID method.

Look at the difference between a Symbol object and a String object:

puts:str.object_id#710748puts:str.object_id#710748puts:str.object_id#710748Puts"..............."puts"Hello". object_id#21458200Puts"Hello". object_id#21458140Puts"Hello". object_id#21458080

Symbol (Colon in Ruby)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.