The enumeration and the output does not match on the ruby enumeration intro page. I propose updating the map block by adding a period (“.”) to match the output example.
#{index}. #{word}" to match 0. the
words = %w[the cat sat on the mat]
list = words.map.with_index do |word, index|
“#{index} #{word}”
end
#{index}. #{word}" to match 0. the
words = %w[the cat sat on the mat]
list = words.map.with_index do |word, index|
“#{index} #{word}”
end
puts list
# Output:
# 0. the
# 1. cat
# 2. sat
# 3. on
# 4. the
# 5. mat