Skip to content

Instantly share code, notes, and snippets.

View AlexHedley's full-sized avatar
💭
⚀⚁⚂⚃⚄⚅

Alex Hedley AlexHedley

💭
⚀⚁⚂⚃⚄⚅
View GitHub Profile
@scotteg
scotteg / printOutSumOfNumber:andNumber:withFormatter:
Last active August 29, 2015 14:06
Example of a Swift function that takes a function as a parameter, nests functions, and returns a function
func formatNumberAsSpelledOutString(number: Any) -> String {
var numberString: String!
let spellOutFormatter = NSNumberFormatter()
spellOutFormatter.numberStyle = .SpellOutStyle
if number is Int {
let num = number as Int
numberString = spellOutFormatter.stringFromNumber(num)
} else if number is Double {
spellOutFormatter.minimumFractionDigits = 1
let num = number as Double