Gaal Yahas wrote:
I know why the following doesn't work:

     given $food {
         when Pizza | Lazagna { .eat }
         when .caloric_value > $doctors_orders { warn "no, no no" }
         # ...

The expression in the second when clause is smart-matched against $food,
not tested for truth like an if.

The smart match is hopefully *type* aware. In the above second case
the match could be :( Item ~~ Code ) the Item is $food, the Code is the
block { .caloric_value > $doctors_orders }. So far so bad, you say?!
But I think the type inferencer will type the Code as :(Item --> bool)
and as such we could specify that a booleanizing, inline block just
does what you expect. If the same should be the case for

   sub foo:( --> bool) {...}

   given $food
       when foo {...} # call foo and enter if true is returned

I would like that.

Reply via email to