Skip to content

Instantly share code, notes, and snippets.

@Insulince
Created September 22, 2018 01:05
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/95556a3c5b925fcf242933420d5398cf to your computer and use it in GitHub Desktop.
Save Insulince/95556a3c5b925fcf242933420d5398cf to your computer and use it in GitHub Desktop.
An example of nesting the Golang version of a JavaScript ternary operation into itself an arbitrary amount of times. Again, and I cannot stress this enough, DO NOT DO THIS.
package main
import (
"fmt"
)
func main() () {
for num := 0; num < 16; num++ {
fmt.Println(num, map[bool]string{
true: map[bool]string{
true: map[bool]string{
true: map[bool]string{
true: "a",
false: "b",
}[num == 0],
false: map[bool]string{
true: "c",
false: "d",
}[num == 2],
}[num < 2],
false: map[bool]string{
true: map[bool]string{
true: "e",
false: "f",
}[num == 4],
false: map[bool]string{
true: "g",
false: "h",
}[num == 6],
}[num < 6],
}[num < 4],
false: map[bool]string{
true: map[bool]string{
true: map[bool]string{
true: "i",
false: "j",
}[num == 8],
false: map[bool]string{
true: "k",
false: "l",
}[num == 10],
}[num < 10],
false: map[bool]string{
true: map[bool]string{
true: "m",
false: "n",
}[num == 12],
false: map[bool]string{
true: "o",
false: "p",
}[num == 14],
}[num < 14],
}[num < 12],
}[num < 8])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment