Built-in Ruby classes that have literal constructors

1, String
Quotation marks
"new string" or 'new string'


2, Symbol
Leading colon
:symbol or :"symbol with spaces"


3, Array
Square brackets
[1, 2, 3, 4, 5]


4, Hash
Curly braces
{"New York" => "NY", "Oregon" => "OR"}


5, Range
Two or three dots
0...10 or 0..9


6, Regexp
Forward slashes
/([a-z]+)/

你可能感兴趣的:(Ruby)