Exercises to grasp and practice fundamental concepts in Ruby.
Hashes have keys and values, and we can look up values easily if we have the key. (The inverse is not necessarily true.).
Strings are everywhere. Let's munge them a bit.
More string stuff.
def test_loop_in_array
people = ["Alice", "Bob", "Charlie"]
# wants one block parameter
people.each do |person|
person.inspect
end
enddef test_loop_in_hash
people = {"Annie" => 39, "Jim" => 10, "Barney" => 12}
# wants two block parameters
people.each do |name, age|
"#{name} is #{age} years old"
end
end