develooper Front page | perl.perl6.users | Postings from June 2018

mixin syntax: does vs but

Thread Next
Joseph Brenner
June 12, 2018 07:06
mixin syntax: does vs but
Message ID:
I thought this would work to make a copy of @x but with the role
"LookInside" attached to it:

   my @y = @x but LookInside;

But that didn't add the role to @y. E.g.

  say @y.^WHAT

Would just report (Array), not (Array+{LookInside}).

I found that this would do what I was trying to do though:

   my @y = @x;
   @y does LookInside;

I didn't think there would be any difference between the two
though.  What am I not getting?

The full code looks like this:


  use v6;
  use Trial::Introspect;
  my @x = <wuhn tew thuree foah fahv sex>;
  my @y = @x;
  @y does LookInside;
  say "Methods: ";
  say @y.methodical_methods;


  role LookInside {
    method methodical_methods {
      self.^{ .gist }){ "$_\n" }).grep({
! /^Method/ });

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About