From type/Any

See primary documentation in context for routine snitch

multi sub snitch(\snitchee)
multi sub snitch(&snitcher, \snitchee)
method snitch(\snitchee: &snitcher = &note)

Available as of 6.e language version (early implementation exists in Rakudo compiler 2022.12+).

The snitch method / subroutine is a debugging / logging tool that will always return any invocant / argument given unchanged.

By default, it will note the invocant / argument, but this can be overridden by specifying a Callable that is expected to take the invocant / argument as its only argument.

(my $a = 42).snitch = 666say $a;  # OUTPUT: «42␤666␤» 
(1..5).snitch;                      # OUTPUT: «1..5␤» 
(1..5).Seq.snitch;                  # OUTPUT: «(1 2 3 4 5)␤» 
(1..5).Seq.snitch(&dd);             # OUTPUT: «(1, 2, 3, 4, 5).Seq␤» 
(1..5).map(*+1).snitch;             # OUTPUT: «(2 3 4 5 6)␤» 
say (1..3).Seq.snitch.map(*+2);     # OUTPUT: «(1 2 3)␤(3 4 5)␤» 

The same, using the feed operator:

(1..3).Seq ==> snitch() ==> map(*+2==> say();  # OUTPUT: «(1 2 3)␤(3 4 5)␤» 

Using a custom logger:

my @snitched;
my @result = (1..3).Seq.snitch({ @snitched.push($_}).map(*+2);
say @snitched;  # OUTPUT: «[(1 2 3)]␤» 
say @result;    # OUTPUT: «[3 4 5]␤»