Skip to content

Commit

Permalink
Add String.each_char.
Browse files Browse the repository at this point in the history
  • Loading branch information
treed committed Aug 7, 2009
1 parent 9165470 commit 31c9263
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/classes/String.pir
Expand Up @@ -480,6 +480,18 @@ Warning: Partial implementation. Look for TODO
each_loop_done:
.end

.sub 'each_char' :method
.param pmc block :named('!BLOCK')
.local pmc iterator, item
iterator = iter self
each_loop:
unless iterator goto each_loop_done
item = shift iterator
block(item)
goto each_loop
each_loop_done:
.end

=item perl()

Returns a Perl representation of the Str.
Expand Down
2 changes: 1 addition & 1 deletion t/string/block.t
@@ -1,6 +1,6 @@
require 'Test'
include Test
plan 6
plan 7

s = String.new("ruby")
isnt s, nil, '.new for String'
Expand Down

0 comments on commit 31c9263

Please sign in to comment.