Skip to content

Instantly share code, notes, and snippets.

@rjbs
Created June 21, 2016 21:06
Show Gist options
  • Save rjbs/1b6673ab637396972d95e9c1294be716 to your computer and use it in GitHub Desktop.
Save rjbs/1b6673ab637396972d95e9c1294be716 to your computer and use it in GitHub Desktop.
#!perl6
#
use v6;
my class HelloWorldFactory {
subset NonEmpty of Str where .chars > 0;
has NonEmpty $.greeting;
has NonEmpty $.target;
sub infix:<👋> {
constant joiner = "\c[COMMA]\c[NO-BREAK SPACE]";
[~] $^greeting, joiner, $^target
}
method hello-world($target = self.target --> NonEmpty) {
$.greeting 👋 $target
}
}
HelloWorldFactory.new(greeting => "Hello", target => "World")
.hello-world
.say;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment