Skip to content

Commit

Permalink
Allow ord to handle a string with more than one character (in list co…
Browse files Browse the repository at this point in the history
…ntext, anyway).
  • Loading branch information
colomon committed Dec 12, 2009
1 parent 6ee78ed commit 6f25191
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/core/Any-str.pm
Expand Up @@ -131,9 +131,16 @@ augment class Any {
Regex::Cursor.parse(self, :rule($pat), :c($c));
}

our Int multi method ord() {
fail('Can not take ord of empty string') if self.chars == 0;
pir::box__PI(pir::ord__IS(self))
our multi method ord() {
given self.chars {
when 0 { fail('Can not take ord of empty string'); }
when 1 { pir::box__PI(pir::ord__IS(self)); }
default {
gather for self.comb {
take pir::box__PI(pir::ord__IS($_))
}
}
}
}

# TODO: Return type should be a Char once that is supported.
Expand Down

0 comments on commit 6f25191

Please sign in to comment.