Rules / Types, classes & roles / basic

Whatever Reference

Placeholder for the value of an unspecified argument

What it is #

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method ACCEPTS #

multi method ACCEPTS(Whatever:D: Mu $other)
multi method ACCEPTS(Whatever:U: Mu $other)

If the invocant is an instance, always returns True. If the invocant is a type object, performs a typecheck.

method Capture #

method Capture()

Throws X::Cannot::Capture.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

10 no-output · 3 ok · 1 rakupp-differs

class Whatever { }

Not executed: the documentation states no expected output for this example.

my $c = * + 2;          # same as   -> $x { $x + 2 };
say $c(4);              # OUTPUT: «6␤»
Output
6

Documentation, Rakudo and Raku++ all agree.

my $c = * + *;          # same as   -> $x, $y { $x + $y }

Not executed: the documentation states no expected output for this example.

my $c = 4 * * + 5;      # same as   -> $x { 4 * $x + 5 }

Not executed: the documentation states no expected output for this example.

<a b c>.map: *.uc;      # same as    <a b c>.map: -> $char { $char.uc }

Not executed: the documentation states no expected output for this example.

Exception           Example     What it does
=========           =======     ============
comma               1, *, 2     generates a List with a * element
range operators     1 .. *      Range from 1 to Inf
series operator     1 ... *     infinite lazy Seq
assignment          $x = *      assign * to $x
binding             $x := *     bind * to $x
list repetition     1 xx *      generates an infinite list

Not executed: the documentation states no expected output for this example.

say (1..*).^name;       # OUTPUT: «Range␤»
say ((1..*-1)).^name;   # OUTPUT: «WhateverCode␤»
Output
Range
WhateverCode

Documentation, Rakudo and Raku++ all agree.

.say for 1..*;          # infinite loop

Not executed: the documentation states no expected output for this example.

my @a = 1..4;
say @a[0..*];           # OUTPUT: «(1 2 3 4)␤»
say @a[0..*-2];         # OUTPUT: «(1 2 3)␤»
Output
(1 2 3 4)
(1 2 3)

Documentation, Rakudo and Raku++ all agree.

my $x = *;
$x + 2;   # Not a closure, dies because it can't coerce $x to Numeric
CATCH { default { put .^name, ': ', .Str } };
# OUTPUT: «X::Multi::NoMatch: Cannot resolve caller Numeric(Whatever: );
# none of these signatures match:␤
# (Mu:U \v: *%_)»

Not executed: the documentation states no expected output for this example.

my $max    = potential-upper-limit() // *;
my $series = known-lower-limit() ... $max;

Not executed: the documentation states no expected output for this example.

my $constraint           = find-constraint() // *;
my $maybe-always-matcher = * ~~ $constraint;

Not executed: the documentation states no expected output for this example.

$maybe-always-matcher(555);      # True
$maybe-always-matcher(Any);      # True

Not executed: the documentation states no expected output for this example.

say 42 ~~ (*);       # OUTPUT: «True␤»
say 42 ~~ Whatever;  # OUTPUT: «False␤»
Documentation
True
False
Rakudo
True
False
Raku++
WhateverCode.new
False

Raku++ disagrees with both the documentation and Rakudo — a defect.