Skip to content

Instantly share code, notes, and snippets.

@Adron
Last active May 20, 2019 01:02
Show Gist options
  • Save Adron/62312b77bd4315214771ebb966575599 to your computer and use it in GitHub Desktop.
Save Adron/62312b77bd4315214771ebb966575599 to your computer and use it in GitHub Desktop.
Creating a Currency Type
type Currency int
const (
USD Currency = iota
CAN
EUR
GBP
JPY
NOK
SEK
DKK
)
symbol := [...]string{USD: "$", CAN: "$", EUR: "€", GBP: "£", JPY:"¥", NOK:"kr", SEK:"kr",DKK:"kr"}
fmt.Println(EUR, symbol[EUR])
fmt.Println(JPY, symbol[JPY])
r := [...]int{99: -1}
r[36] = 425
r[42] = 42
fmt.Println(r[36] + r[42])
fmt.Println(strconv.Itoa(r[36]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment