coding for food
[Ruby] hashes data type
silveryen
2022. 8. 4. 03:40
# good array data
animals = ["dog", "cat", "fish", "bird", "rabbit"]
# not so good array data
person = ["Kim", 100, "New York", "burger", true ]
# better as hash
better_person = {
"name" => "Kim",
"age" => 100,
"location" => "New York",
"favoritFood" => "burger",
"isHungry" => true
}
puts better_person["location"]
---------------------------------
#=>
New York