Skip to content

Commit e95983f

Browse files
authored
Make &[max] and &[min] return LHS for ties (#4084)
1 parent 67b76cf commit e95983f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

doc/Language/operators.pod6

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,13 +2720,33 @@ Returns the smallest of the arguments, as determined by L<cmp|/routine/cmp> sema
27202720
my $foo = 42;
27212721
$foo min= 0 # read as: $foo decreases to 0
27222722
2723+
B<Note:> Before 2022.06, in the cases of ties L<C<&min>|/type/Any#routine_min>
2724+
would return the first argument with that value, whereas C<&[min]> would return
2725+
its RHS. After 2022.06, C<&[min]> returns its LHS in the case of ties, and now
2726+
both return the same value as dictated by their List associativity.
2727+
2728+
say min 0, False; # OUTPUT: «0»
2729+
say 0 min False; # OUTPUT: «0»
2730+
say min False, 0; # OUTPUT: «False»
2731+
say False min 0; # OUTPUT: «False»
2732+
27232733
=head2 infix C«max»
27242734
27252735
Returns the largest of the arguments, as determined by L<cmp|/routine/cmp> semantics.
27262736
27272737
my $foo = -42;
27282738
$foo max= 0 # read as: $foo increases to 0
27292739
2740+
B<Note:> Before 2022.06, in the cases of ties L<C<&max>|/type/Any#routine_max>
2741+
would return the first argument with that value, whereas C<&[max]> would return
2742+
its RHS. After 2022.06, C<&[max]> returns its LHS in the case of ties, and now
2743+
both return the same value as dictated by their List associativity.
2744+
2745+
say max 0, False; # OUTPUT: «0»
2746+
say 0 max False; # OUTPUT: «0»
2747+
say max False, 0; # OUTPUT: «False»
2748+
say False max 0; # OUTPUT: «False»
2749+
27302750
=head2 infix C«minmax»
27312751
27322752
Returns the L<Range|/type/Range> starting from the lowest to the highest of the values,

0 commit comments

Comments
 (0)