Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/448480 to your computer and use it in GitHub Desktop.
Save masak/448480 to your computer and use it in GitHub Desktop.
$ ./perl6 t/spec/S32-str/encode.t
1..13
ok 1 - $str.encode returns a Buf
ok 2 - encoding to ASCII
ok 3 - right length of Buf
ok 4 - encoding to UTF-8
ok 5 - right length of Buf
get_pmc_keyed() not implemented in class ''
in 'at_pos' at line 1056:CORE.setting
in 'postcircumfix:<[ ]>' at line 1053:CORE.setting
in main program body at line 1
$ git diff
diff --git a/src/core/Buf.pm b/src/core/Buf.pm
index 5d7d7d8..457e5ee 100644
--- a/src/core/Buf.pm
+++ b/src/core/Buf.pm
@@ -1,4 +1,4 @@
-role Buf[::T = Int] does Stringy {
+role Buf[::T = Int] does Stringy does Positional {
has T @.contents;
multi method new(@contents) {
@@ -34,6 +34,10 @@ role Buf[::T = Int] does Stringy {
multi method elems() {
@.contents.elems;
}
+
+ multi method postcircumfix:<[ ]>(*@indices) {
+ @.contents[|@indices];
+ }
}
our multi sub infix:<eqv>(Buf $a, Buf $b) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment