Skip to content

Commit 425976f

Browse files
committed
Any: examples
1 parent f776ede commit 425976f

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

lib/Type/Any.pod

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,54 @@ List or a list-like type.
2222
2323
Returns C<True> if C<$other === self> (i.e. it checks object identity).
2424
25+
Many built-in types override this for more specific comparisons
26+
2527
=head2 method any
2628
27-
Interprets the invocant as a list and creates an C<any>-Junction from it.
29+
method any() returns Junction:D
30+
31+
Interprets the invocant as a list and creates an
32+
C<any>-L<Junction|/type/Junction> from it.
33+
34+
say so 2 == <1 2 3>.any; # True
35+
say so 5 == <1 2 3>.any; # False
2836
2937
=head2 method all
3038
31-
Interprets the invocant as a list and creates an C<all>-Junction from it.
39+
method all() returns Junction:D
40+
41+
Interprets the invocant as a list and creates an
42+
C<all>-L<Junction|/type/Junction> from it.
43+
44+
say so 1 < <2 3 4>.all; # True
45+
say so 3 < <2 3 4>.all; # False
3246
3347
=head2 method one
3448
35-
Interprets the invocant as a list and creates an C<one>-Junction from it.
49+
method one() returns Junction:D
50+
51+
Interprets the invocant as a list and creates an
52+
C<one>-L<Junction|/type/Junction> from it.
53+
54+
say so 1 == (1, 2, 3).one; # True
55+
say so 1 == (1, 2, 1).one; # False
3656
3757
=head2 method none
3858
39-
Interprets the invocant as a list and creates an C<none>-Junction from it.
59+
method none() returns Junction:D
60+
61+
Interprets the invocant as a list and creates an
62+
C<none>-L<Junction|/type/Junction> from it.
63+
64+
say so 1 == (1, 2, 3).none; # False
65+
say so 4 == (1, 2, 3).none; # True
4066
4167
=head2 method list
4268
43-
Interprets the invocant as a list, and returns that list.
69+
Interprets the invocant as a list, and returns that L<List|/type/List>.
70+
71+
say so 42.list.^name; # List
72+
say so 42.list.elems; # 1
4473
4574
=head2 method flat
4675
@@ -54,15 +83,23 @@ Interprets the invocant as a list, flattens it, and returns that list.
5483
Interprets the invocant as a list, evaluates it eagerly, and returns that
5584
list.
5685
86+
say (1..10).eager; # 1 2 3 4 5 6 7 8 9 10
87+
5788
=head2 method elems
5889
5990
Interprets the invocant as a list, and returns the number of elements in the
6091
list.
6192
93+
say 42.elems; # 1
94+
say <a b c>.elems; # 3
95+
6296
=head2 method end
6397
6498
Interprets the invocant as a list, and returns the last index of that list.
6599
100+
say 6.end; # 0
101+
say <a b c>.end; # 2
102+
66103
=head2 sub exit
67104
68105
sub exit(Int() $status = 0)

0 commit comments

Comments
 (0)