FAQ
In Go you can use the syntax a op= b as a shorthand for a = a op b
with a being evaluated only once. With this in mind I tried to write a
program that contained a code fragment similar to this one:

func all([]bool sl) (b bool) {
b = true

for i:=0; i<len(sl); i++ {
b &&= sl[i]
}

return
}


only to find out that said code does not work. The Go 1 language does
neither support &&= not ||=. I also tried using &= and |= only to find out
that they are not defined on bools.

What I want to know is:

- Why are there no &&= and ||= operators even though this kind of
operators exist for all other operators? It would be consequent, simple and
easy to understand
- Why are the & and | operators not applicable to booleans? It would
make perfect sense to see a boolean as a one-bit wide (unsigned) integer in
many cases. Also, what if I don't want short-circuit evaluation?

Thank you very much for your help in advance.

Yours, Robert Clausecker

--
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 golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 21 | next ›
Discussion Overview
groupgolang-nuts @
categoriesgo
postedMar 1, '13 at 7:02p
activeMar 3, '13 at 2:38a
posts21
users9
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase