Created
September 22, 2018 01:02
-
-
Save Insulince/36643ad2854ffbb6a7312821e30cb546 to your computer and use it in GitHub Desktop.
Emulation of a JavaScript ternary operation in Golang. I would not recommend ever actually using this, just use an if.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func main() () { | |
predicate := true | |
fmt.Println(map[bool]string{true: "a", false: "b"}[predicate]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment