Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created May 21, 2014 14:42
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 jnthn/cd062dfa6bccf8f95e2d to your computer and use it in GitHub Desktop.
Save jnthn/cd062dfa6bccf8f95e2d to your computer and use it in GitHub Desktop.
diff --git a/src/core/IO.pm b/src/core/IO.pm
index 5067ef5..8039ca7 100644
--- a/src/core/IO.pm
+++ b/src/core/IO.pm
@@ -6,10 +6,15 @@ sub print(|) {
Bool::True
}
-sub say(|) {
+proto sub say(|) { * }
+multi sub say(\x) {
+ $*OUT.say(x);
+}
+multi sub say(|) {
my $args := nqp::p6argvmarray();
- $*OUT.print(nqp::shift($args).gist) while $args;
- $*OUT.print("\n");
+ my $out := $*OUT;
+ $out.print(nqp::shift($args).gist) while $args;
+ $out.print("\n");
}
sub note(|) {
@@ -265,11 +270,15 @@ my class IO::Handle does IO::FileTestable {
Bool::True
}
+ multi method say(IO::Handle:D: \x) {
+ nqp::sayfh($!PIO, x.gist);
+ }
+
multi method say(IO::Handle:D: |) {
my Mu $args := nqp::p6argvmarray();
nqp::shift($args);
- self.print: nqp::shift($args).gist while $args;
- self.print: "\n";
+ nqp::printfh($!PIO, nqp::shift($args).gist) while $args;
+ nqp::printfh($!PIO, "\n");
}
method slurp(:$bin, :enc($encoding)) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment