[Ruby] Ruby Symbol

http://www.troubleshooters.com/codecorn/ruby/symbols.htm 

Ruby 里的Symbol概念的讲解,

What are symbols?

It's a string. No it's an object. No it's a name.

puts  :Steve.class  # output : Symbol Class

 Symbol can not change at runtime 

 

What can symbols do for you?

A symbol is a way to pass string information, always assuming that:

    1. The string needn't be changed at runtime.
    2. The string doesn't need methods of class String.
posted @ 2013-05-04 17:27  卜海清  阅读(197)  评论(0编辑  收藏  举报