| 38 | | }; |
| | 36 | { |
| | 37 | # combined regex / closure |
| | 38 | my $count = 0; |
| | 39 | is 'hello'.trans(/l/ => { ++$count }), 'he12o', 'regex and closure mix'; |
| | 40 | is 'hello'.trans(/l/ => { $_ x 2 }), 'hellllo', 'regex and closure mix (with $/ as topic)'; |
| | 41 | is 'hello'.trans(/(l)/ => { $_[0] x 2 }), 'hellllo', 'regex and closure mix (with $/ as topic and capture)'; |
| | 42 | } |
| | 43 | |
| | 44 | #?rakudo todo 'Str.trans with regex+closure, RT #59730' |
| | 45 | is 'hello'.trans(/(l)/ => { $_[0].ord }), 'he108108o', 'capturing regex + closure with .ord on $_'; |