Logo

Programming-Idioms

History of Idiom 131 > diff from v1 to v2

Edit summary for version 2 by programming-idioms.org:
[Go] +DocURL

Version 1

2016-05-03, 12:37:42

Version 2

2016-05-03, 12:39:15

Idiom #131 Successive conditions

Execute f1 if condition c1 is true, or else f2 if condition c2 is true, or else f3 if condition c3 is true.
Don't evaluate a condition when a previous condition was true.

Idiom #131 Successive conditions

Execute f1 if condition c1 is true, or else f2 if condition c2 is true, or else f3 if condition c3 is true.
Don't evaluate a condition when a previous condition was true.

Extra Keywords
else switch case
Extra Keywords
else switch case
Code
switch {
case c1():
	f1()
case c2():
	f2()
case c3():
	f3()
}
Code
switch {
case c1():
	f1()
case c2():
	f2()
case c3():
	f3()
}
Doc URL
https://golang.org/ref/spec#Switch_statements
Demo URL
https://play.golang.org/p/h_JtnJLJVR
Demo URL
https://play.golang.org/p/h_JtnJLJVR