Skip to content

Instantly share code, notes, and snippets.

@nazrdogan
Created March 25, 2018 19:17
Show Gist options
  • Save nazrdogan/1423aa02b6971d5b4839b462c6ef7701 to your computer and use it in GitHub Desktop.
Save nazrdogan/1423aa02b6971d5b4839b462c6ef7701 to your computer and use it in GitHub Desktop.
func convertToTL(price:String) -> String {
let count = price.count;
if (count <= 2){
return "0.\(price) TL"
}
else {
let suffix = price.suffix(2)
let prefix = price.prefix(count - 2)
return "\(prefix).\(suffix) TL"
}
}
convertToTL(price: "6")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment