Skip to content

Instantly share code, notes, and snippets.

@balsikandar
Created May 1, 2021 16:57
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 balsikandar/56ceb6f33aa9b2a7a336151fd24ddc78 to your computer and use it in GitHub Desktop.
Save balsikandar/56ceb6f33aa9b2a7a336151fd24ddc78 to your computer and use it in GitHub Desktop.
This Gist
class Currency {
val map = HashMap<String, String>();
init {
map.put("India", "Rupee")
map.put("UK", "Euro")
map.put("Japan", "Yen")
map.put("USA", "Dollar")
map.put("China", "Yuan")
}
fun getCurrencyNameOf(country: String): String {
return map.get(country) ?: "NA"
}
}
// Call getCurrencyOf from anywhere now by passing string
fun main() {
val currency = Currency()
val indianCurrency = currency.getCurrencyNameOf("India")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment