method Set

Documentation for method Set assembled from the following types:

class List

From List

(List) method Set

In general, creates a set which has as members elements of the list.

say <æ ß þ €>.Set;  # OUTPUT: «set(ß æ þ €)␤»

However, there might be some unexpected changes in case the list includes non-scalar data structures. For instance, with Pairs:

my @a = (:42a, :33b);
say @a;                # OUTPUT: «[a => 42 b => 33]␤» 
say @a.Set;            # OUTPUT: «set(a b)␤»

The set will be composed of the keys of the Pair whose corresponding value is not 0, eliminating all the values. Please check the Set documentation for more examples and a more thorough explanation.

class Any

From Any

(Any) method Set

Defined as:

method Set(--> Set:Dis nodal

Coerces the invocant to Set, whereby Positionals are treated as lists of values.

role Baggy

From Baggy

(Baggy) method Set

Defined as:

method Set(--> Set:D)

Returns a Set whose elements are the keys of the invocant.

my $breakfast = (eggs => 2bacon => 3).BagHash;
say $breakfast.Set;                               # OUTPUT: «set(bacon, eggs)␤»