Last active
May 20, 2019 01:02
-
-
Save Adron/62312b77bd4315214771ebb966575599 to your computer and use it in GitHub Desktop.
Creating a Currency Type
This file contains hidden or 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
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