Skip to content

Instantly share code, notes, and snippets.

@dakkar

dakkar/Plop.pm6 Secret

Forked from Skarsnik/Plop.pm6
Last active September 16, 2020 10:03
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 dakkar/1af4796894f695ceee13da925924fa6f to your computer and use it in GitHub Desktop.
Save dakkar/1af4796894f695ceee13da925924fa6f to your computer and use it in GitHub Desktop.
use v6.d;
class A {
multi method put-address(Int $addr, Blob $data, :$space = 'SNES') {
say "int-blob";
}
multi method put-address(**@args, :$space = 'SNES') {
my @params;
my @datas;
for @args -> $arg {
say $arg.raku, $arg.WHAT.raku;
say "I am a list" if $arg ~~ List;
@params.push(($arg[0].base(16), $arg[1].base(16))) if $arg ~~ List;
@datas.push($arg) if $arg ~~ Blob;
}
say @params.raku, @datas.raku;
return;
}
}
A.new.put-address((0xF50050, 4), (0xF50054, 2), Buf.new(<1 2 3 4>), Buf.new(<5 6>));
__END__
$ raku x.raku
$(16056400, 4)List
I am a list
$(16056404, 2)List
I am a list
Buf.new(1,2,3,4)Buf
Buf.new(5,6)Buf
[("F50050", "4"), ("F50054", "2")][Buf.new(1,2,3,4), Buf.new(5,6)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment