Symbol in an array : Symbols « Language Basics « Ruby






Symbol in an array


myArray = ["January", 1, :year, [2006,01,01]]

myArray.each {|e| print e.class, " " } # => String Fixnum Symbol Array

 








Related examples in the same category

1.symbols is placeholders for identifiers and strings.
2.Ruby uses tons of symbols internally. To prove it, execute this line of Ruby code
3.id2name
4.Using Symbols as Hash Keys
5.object_id of three string with the same value
6.object_id of three symbols with the same name