Skip to content

Instantly share code, notes, and snippets.

@Adron

Adron/currency.go

Last active May 20, 2019
Embed
What would you like to do?
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