Processing a String One Character at a Time


(For all intents and purposes, this project is dead, but let us just call it "Deferred Indefinitely". Shall we?)

Problem

You need to iterate over every character in a string.

Solution

Use the each_byte string iterator:

aString.each_byte {
  |c|
  # do something with c
}

Discussion

Strings are enumerable. This means that you have a number of predefined methods for enumerating or iterating over each element of the collection. each_byte is a specialization of the String#each which allows you to specify your separator so you can iterate over characters, words, sentances or whatever.

Contrast

Related

Status: In Progress