Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Space-invader operator C< -+- > #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion lib/perlsecret.pod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Perl secret operators:
~- Inchworm on a stick high-precedence decrement
-~ Inchworm on a stick high-precedence increment
-+- Space station high-precedence numification
-=- Space-invader add to
=( )= Goatse scalar / list context
=< >=~ Flaming X-Wing match input, assign captures
~~<> Kite a single line of input
Expand Down Expand Up @@ -452,6 +453,18 @@ or I<strings that do not start with a number>:
In the above example, C<-+- '-2B'> produces the string C<'-2B'>,
whereas C<0+ '-2B'> would have given the expected number (C<-2>).

=head2 Space-invader

-=-

L<Stolen|https://twitter.com/raymondh/status/1131103570856632321> from Python
by Brian Greenfield, 2019.

An alternative spelling of C< += >.

$n = 5;
$n -=- 3;
say $n; # 8

=head2 Goatse

Expand Down Expand Up @@ -1112,4 +1125,3 @@ This documentation is free; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

7 changes: 7 additions & 0 deletions t/secret.t
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,13 @@ use warnings;
is( -+- 'two cents', '+two cents', '-+- exception' );
is( -+- '-2B' x 5, '-2B-2B-2B-2B-2B', '-+- exception' );

# space-invader
my $n5 = -2;
$n5 -=- 0;
is( $n5, -2, '-=-' );
$n5 -=- 3;
is( $n5, 1, '-=-' );

# goatse
my $n;
$_ = "word2 and word3";
Expand Down