Skip to content
Permalink
Browse files

Merge pull request #593 from kachick/implement-string-each_char

Implement String#each_char, String#chars
  • Loading branch information
alex committed Apr 11, 2013
2 parents 36a0f33 + 31a8398 commit 429a83e2e7eec693fb533b256d6e718d3e7c296b
Showing with 14 additions and 6 deletions.
  1. +14 −0 lib-topaz/string.rb
  2. +0 −3 spec/tags/core/string/chars_tags.txt
  3. +0 −3 spec/tags/core/string/each_char_tags.txt
@@ -60,6 +60,20 @@ def succ
end
alias next succ

def each_char(&block)
return self.enum_for(:each_char) unless block

i = 0
limit = self.length
while i < limit
yield self[i]
i += 1
end

self
end
alias chars each_char

def upto(max, exclusive = false, &block)
return self.enum_for(:upto, max, exclusive) unless block

@@ -1,4 +1 @@
fails:String#chars passes each char in self to the given block
fails:String#chars returns self
fails:String#chars is unicode aware
fails:String#chars returns an enumerator when no block given
@@ -1,4 +1 @@
fails:String#each_char passes each char in self to the given block
fails:String#each_char returns self
fails:String#each_char is unicode aware
fails:String#each_char returns an enumerator when no block given

0 comments on commit 429a83e

Please sign in to comment.