Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2014
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. use v6;
  2.  
  3. my Str $sep = "x";
  4. my Str $buf = q{abcxdefx1};
  5.  
  6. "No class:".say;
  7. .say for $buf.split(rx{ $sep }, :all).map(~*);
  8.  
  9. class Foo {
  10. has Str $.sep is rw = 'x';
  11.  
  12. method p (Str $b) {
  13. my Str $s = $!sep;
  14.  
  15. "Class with copy".say;
  16. for $b.split(rx{ $s }, :all).map(~*) {
  17. .say;
  18. }
  19.  
  20. "Class direct".say;
  21. for $b.split(rx{ $!sep }, :all).map(~*) {
  22. .say;
  23. }
  24. }
  25. }
  26.  
  27. Foo.new.p($buf);
  28.  
  29. =>
  30.  
  31. No class:
  32. abc
  33. x
  34. def
  35. x
  36. 1
  37. Class with copy
  38. abc
  39. x
  40. def
  41. x
  42. 1
  43. Class direct
  44. abcxdefx1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement