Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use v6;
- my Str $sep = "x";
- my Str $buf = q{abcxdefx1};
- "No class:".say;
- .say for $buf.split(rx{ $sep }, :all).map(~*);
- class Foo {
- has Str $.sep is rw = 'x';
- method p (Str $b) {
- my Str $s = $!sep;
- "Class with copy".say;
- for $b.split(rx{ $s }, :all).map(~*) {
- .say;
- }
- "Class direct".say;
- for $b.split(rx{ $!sep }, :all).map(~*) {
- .say;
- }
- }
- }
- Foo.new.p($buf);
- =>
- No class:
- abc
- x
- def
- x
- 1
- Class with copy
- abc
- x
- def
- x
- 1
- Class direct
- abcxdefx1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement