Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created October 29, 2011 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/1324549 to your computer and use it in GitHub Desktop.
Save atduskgreg/1324549 to your computer and use it in GitHub Desktop.
Loop over the characters in a string
text = "here is my string"
for letter in text.split("")
puts letter
end
@ybakos
Copy link

ybakos commented Dec 23, 2013

Neat, but explore Ruby iterators. For example:
text.chars.each {|c| puts c}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment