Skip to content

Instantly share code, notes, and snippets.

@lmars
Created February 29, 2012 10:27
Show Gist options
  • Save lmars/1939737 to your computer and use it in GitHub Desktop.
Save lmars/1939737 to your computer and use it in GitHub Desktop.
Iterating over a string
string = 'ABCDE'
string.reverse.each_char do |numeral|
# inside this block numeral will be a character from the string
puts numeral
end
# This will output:
E
D
C
B
A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment