switch statement versus ~~

colomon on 2008-12-24T13:52:36

I would have thought

        given $c
        {
            when $c ~~ /defDEF/ { $c = '3'; }
        }
would have worked? This isn't a big deal, it's easy enough to work around, but it does lose elegance points.

PS Looks like $s.substr($i,1) = $c; doesn't work yet, either? Or is there something wrong with the syntax of that?


'when' smartmatches

tene on 2008-12-24T23:22:51

given $c {
    when /defDEF/ { $c = 3 }
}

Re:'when' smartmatches

colomon on 2008-12-25T01:40:50

Duh! Right. Two years ago I knew that.

However, when I try that now, it doesn't seem to actually work. It compiles okay, but none of the matches seem to fire...