Ruby Challenges - Analyzing Shakespeare

Continuing the discussion from New trail: Ruby Challenges:

I think the root issue is that you’re not sure how each_with_object works. That’s okay, by the way :smile:.

Let’s simplify the example a little bit. I’m going to give you a simpler challenge that I think will help you understand things.

Write a method that takes an array of strings and returns a hash where the keys are the strings, and the values are their lengths.

Example:

def strings_to_lengths(strings)
  # You write this part. Use each_with_object.
end

# Expected results:
strings = ["ben", "eric", "nathan"]
strings_to_lengths(strings) # Returns: { "ben" => 3, "eric" => 4, "nathan" => 6 } 

I think when you solve this, you’ll be well on your way to understanding how your more-complicated example works.