Guest User

Untitled

a guest
May 25th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. role Bar {
  2. COMPOSE {
  3. print "Bar() was composed into: ";
  4. print $_; # => What your being composed into
  5. print " and {$_} was defined: ";
  6. say $_.defined; # How to tell if its a class instance or an object instance
  7. }
  8. }
  9.  
  10. class Foo does Bar {
  11. INHERIT {
  12. print "Foo() was inherited into child: ";
  13. print $_; # => What your being inherited into
  14. }
  15. }
  16.  
  17. class Child is Foo {
  18. }
  19.  
  20. class GrandChild is Child {
  21. }
  22.  
  23. my $i = 123;
  24.  
  25. $i does Bar;
  26.  
  27. =begin pod
  28. expected output:
  29.  
  30. Bar() was composed into: Foo() and Foo() was defined: 0
  31. Foo() was inherited into child: Child()
  32. Foo() was inherited into child: GrandChild()
  33. Bar() was composed into: 123 and 123 was defined: 1
  34.  
  35. =end pod
Add Comment
Please, Sign In to add comment