my $answer = $choice_1 or $choice_2; # this is wrong it turns into
(my $answer = $choice_1) # or $choice_2
> there $choice_2 is only evaluated if the $answer got assigned a false
value, and then it gets evaluated in void context, discarding its value.
> Try this in Raku - what does it say? Do you
@a = @b || @c; # this is wrong
@a = scalar(@b) || @c; # really meant this
"or" doesn't help with this either
@a = @b or @c; # this is wrong
(@a = scalar(@b)) or @c; # really meant this - @c never is
assigned to @Helen Block
the
I always took [1]
As alternatives to "&&" and "||" when used for control flow, Perl provides
the "and" and "or" operators (see below). The short-circuit behavior is
identical. The precedence of "and" and "or" is much lower, however, so
that you can safely use them after a list operato
And then nobody mentions that `and` has low priority. Try `say 42 & 13` and
`say 42 and 13`.
Best regards,
Vadim Belman
> On Jun 30, 2023, at 9:45 AM, yary wrote:
>
> Most of Richard's parting suggestions I understand & agree with, but not
> this: " why are you using '&&' and not 'and' "
>
Most of Richard's parting suggestions I understand & agree with, but not
this: " why are you using '&&' and not 'and' "
My habit (from Perl 5 days) is to use && || for expressions, and reserve
"and" "or" for "do this if assignment/function call without parens
succeeds/fails" – is there a refinemen
I tried this and it worked without any problem.
Here's the whole program:
use v6.d;
say @*ARGS.raku;
if @*ARGS.elems > 0 && "@*ARGS[0]".lc eq "debug" {
say 'got' }
and at the terminal:
$ raku todd-test.raku debug --debug=50
["debug", "--debug=50"]
got
FWIW
why are you quoting ARGS? The .l