Created
February 29, 2012 10:27
-
-
Save lmars/1939737 to your computer and use it in GitHub Desktop.
Iterating over a string
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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