Skip to content

Instantly share code, notes, and snippets.

@Insulince
Created September 22, 2018 01:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Insulince/36643ad2854ffbb6a7312821e30cb546 to your computer and use it in GitHub Desktop.
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.
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