My initial code was sloppy, sorry about that. But you get the idea:
testing if uint is "less than zero" is sometimes legit.
func log(msg string, level uint) {
if level < appLevel {
return
}
triggerBigNetworkLogTool(msg)
}
https://play.golang.org/p/v-7OcDCzmj
On Tuesday, May 23, 2017 at 5:27:26 PM UTC+2, Val wrote:
>
> FWIW, consider first that :
>
> if false {
> foo()
> bar()
> }
>
> is legal (and sometimes recommended by autorities, as opposed to
> momentarily commenting out a block, and struggling with unused vars);
> and second that :
>
> func log(msg string, level uint) {
> if level < appLevel {
> triggerBigNetworkLogTool(msg)
> }
> }
>
> is legal and useful, even if appLevel happens to be a uint constant with
> value 0. See https://play.golang.org/p/nGbELUdvvu
>
> The current policy seems to be: a unused variable is always regarded as a
> compilation error, but unreachable code (dead code) is never a compilation
> error.
>
> On Tuesday, May 23, 2017 at 1:13:28 PM UTC+2, JuciĆ Andrade wrote:
>>
>> Now I understand it.
>> Thank you, guys.
>>
>
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.