Ruby for Instance / Hash

# Define a hash of numbers
numbers = {
  1 => "one",
  2 => "two",
  3 => "three",
  4 => "four",
  5 => "five"
}

# Define a hash of mixed data types
mixed = {
  "hello" => 42,
  true => [1, 2, 3],
  :symbol => "symbol"
}

# Define an empty hash
empty = {}

# Define a hash with symbol keys
symbols = {
  :one => 1,
  :two => 2,
  :three => 3
}

Try on playground

Next: each

made with by dfxe / source / license