Skip to content

Instantly share code, notes, and snippets.

@thinkclay
Created November 19, 2014 20:36
Show Gist options
  • Select an option

  • Save thinkclay/ab0112492d6e4605ebc0 to your computer and use it in GitHub Desktop.

Select an option

Save thinkclay/ab0112492d6e4605ebc0 to your computer and use it in GitHub Desktop.
class CurrencyFactory
{
class func currencyForCountry(country:Country) -> Currency?
{
switch country
{
case .Spain, .France :
return Euro()
case .UnitedStates :
return UnitedStatesDolar()
default: return nil
}
}
}
let noCurrencyCode = "No Currency Code Available"
CurrencyFactory.currencyForCountry(.Spain)?.code() ?? noCurrencyCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment