oclockvn
3/21/2019 - 4:11 PM

Ruby hashes

Ruby hashes

obj = Hash.new
#or
obj = {
    "old_syntax" => 'value 1',
    :old_syntax_too => "value 2",
    new_syntax: "value 3"
}

obj[:assign_sym] = 123

#get value
obj[:new_syntax] #=> "value 3"