in reply to Re^4: printing unitialized value of the 'do BLOCK'
in thread printing unitialized value of the 'do BLOCK'
Nothing ever wants the value of an if statement.
A plain if? Probably not. An if/elsif/else statement though?
my @classifications = map { if ($_ > 0) { 'positive' } elsif ($_ < 0) { 'negative' } else { 'zero' } } @numbers;
Yes, you can write that using the ternary operator, but if/elsif/else can sometimes be clearer.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: printing unitialized value of the 'do BLOCK'
by haukex (Archbishop) on Dec 17, 2019 at 21:42 UTC | |
|
Re^6: printing unitialized value of the 'do BLOCK'
by ikegami (Patriarch) on Dec 18, 2019 at 19:09 UTC |