#!/usr/bin/env perl6 use v6; class MyClass { has $.length is rw; has $.height is rw; has $.color is rw; method my_method ( Array $list, Hash $opt? ) { if defined $opt { for %$opt.keys -> $key { when $key eq 'length' { $!length = $opt{$key}; } when $key eq 'height' { $!height = $opt{$key}; } when $key eq 'color' { $!color = $opt{$key}; } } } } } my $n = MyClass.new(); $n.my_method( [ 1, 2, 3 ], { length => 10, height => 6, color => 'green' }); say $n.perl;