Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improve infix:<x>
  • Loading branch information
zoffixznet committed Oct 16, 2016
1 parent f6314f6 commit 9677f76
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions doc/Language/operators.pod6
Expand Up @@ -1053,28 +1053,20 @@ operation.
=head2 infix C«x»
=begin code :skip-test
proto sub infix:<x>(Any, Any) returns Str:D
multi sub infix:<x>(Any, Any)
multi sub infix:<x>(Str:D, Int:D)
sub infix:<x>($a, $b) returns Str:D
=end code
X<String repetition operator>.
Coerces C<$a> to L<Str> and C<$b> to L<Int> and repeats the string C<$a> C<$b>
times. Return the empty string if C<< $b <= 0 >>.
Repeats the string C<$a> C<$b> times, if necessary coercing C<$a> to L«C<Str>|/type/Str»
and C<$b> L«C<Int>|/type/Int». Returns an empty string if C<< $b <= 0 >>.
say 'ab' x 3; # ababab
say 42 x 3; # 424242
my $a = 'a'; my $b = 3;
my $a = 'a'.IO; my $b = 3.5;
say $a x $b; # aaa
Note there is currently no warning to the user when C<$b> is coerced to a zero or negative integer:
say 5 x ' '; # ''
say 5 x 'a'; # ''
my $a = 3; my $b = 'a';
say $a x $b; # ''
=head2 infix C«xx»
=begin code :skip-test
Expand Down

2 comments on commit 9677f76

@tbrowder
Copy link
Member

@tbrowder tbrowder commented on 9677f76 Oct 17, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the warning? And why the 'a'.IO?

@slobo
Copy link

@slobo slobo commented on 9677f76 Oct 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd imagine 'a'.IO x 3.5 is to further illustrate the coercion to Str and Int....

Please sign in to comment.