Mastering Enumerable, Part 1

Flashcard 1 of 7

What Enumerable method is this code inadvertently reimplementing?

def string_lengths(strings)
  lengths = {}

  strings.each do |string|
    lengths[string] = string.length
  end

  lengths
end

# string_lengths(%w(ben chris mark)) =>
#   { "ben" => 3, "chris" => 5, "mark" => 4 }

Answer:

Reveal Answer