From 6f251913bf1c87f5a9869f3bfe5ab22919dbec5f Mon Sep 17 00:00:00 2001 From: Solomon Foster Date: Sat, 12 Dec 2009 10:10:59 -0500 Subject: [PATCH] Allow ord to handle a string with more than one character (in list context, anyway). --- src/core/Any-str.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/Any-str.pm b/src/core/Any-str.pm index c43410e62cf..13bfc085462 100644 --- a/src/core/Any-str.pm +++ b/src/core/Any-str.pm @@ -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.