Does the String object come with a built in index?

“Hello World”.each_char.with_index {|c, i|
puts “#{i}: #{c}”}

I don’t quite understand where does the index come from. Does any String object in ruby come automatically with an attached index or is the my string being converted to an array by the #.each_char.with_index methods?

#each_char makes your string an enumerable, and #with_index is a method of the enumerable. This adds the index to any enumerable and returns a new enumerable.