Downto method does not work with strings


#1



https://www.codecademy.com/courses/ruby-beginner-en-1o8Mb/2/2?curriculum_id=5059f8619189a5000201fbcb#


Both in the code editor and in a real-life ruby interpreter, I get the following error message:

undefined method `downto' for "Z":String

It's rather misleading to infer, and to allow students to infer, that the "downto" method works with strings because the "upto" method does. There should be a disclaimer about this.


# Write your code below!
# This works
"L".upto("P") { |letter| puts letter }
# This doesn't work
"Z".downto("S") { |new_letter| puts new_letter }


#2

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.