is there short version in Go to reverse a boolean?
instead of:
b := true
if b {
b = false
} else {
b = true
}
is there short version in Go to reverse a boolean?
instead of:
b := true
if b {
b = false
} else {
b = true
}
收起
Yes, just do b = !b
. Here is a playground link where you can see it in action.
报告相同问题?