bitSet := true var bitSetVar int8 How can I assign bitSet to bitSetVar as 1
I can do this:
if bitSet { bitSetVar = 1 } else { bitSetVar = 0 } Is this the best way?
Because the zero value for a int8 is 0, the else branch is not necessary.
bitSet := true var bitSetVar int8 if bitSet { bitSetVar = 1 } There are no conversions from bool to integer types. The if statement is the best you can do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With