Quick actions

cmd+k|ctrl+k

Navigation

Languages

Semi-Dynamic method calling

Snippet info

Language

Raku

Visibility

public

Author

theangryepicbanana

Created

2018-07-28T21:51:18Z

Updated

2018-07-28T22:04:15Z

my $m = "split";

my $s = "banana mango apple";

sub get-method(\value, Str $method) {
    #my %methods = gather {
    #    take Pair.new(.gist, $_) if .^name ~~ "Method" for value.^methods;
    #}.Hash;
    #return -> *@args {%methods{$method}(value, |@args)}
    
    # Compressed version of the code above:
    return -> *@args {(gather {take Pair.new(.gist, $_) if .^name ~~ "Method" for value.^methods}.Hash){$method}(value, |@args)}
}



say $s.&get-method($m)(" ")

INFO