What is the result of Perl's &&?

前端 未结 3 1057
野趣味
野趣味 2021-01-18 12:29

When I try this:

$a = 1;
$b = 2;
print ($a && $b) . \"\\n\";

The result is 2. Why?

3条回答
  •  情歌与酒
    2021-01-18 13:07

    Because the && operator evaluates the right operand and returns the result when the left operand evaluates to true.

提交回复
热议问题