Created
October 29, 2011 14:56
-
-
Save atduskgreg/1324549 to your computer and use it in GitHub Desktop.
Loop over the characters in 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
text = "here is my string" | |
for letter in text.split("") | |
puts letter | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Neat, but explore Ruby iterators. For example:
text.chars.each {|c| puts c}