//: Playground - noun: a place where people can play
import UIKit
let animals = ["fish", "cat", "chicken", "dog"]
let sortedString = animals.sort({(one: String, two: String) -> Bool in
return one < two
})
let sortedString2 = animals.sort({(one, two) -> Bool in
return one < two
})
let sortedString3 = animals.sort({(one, two) in
return one < two
})
let sortedString4 = animals.sort({one, two in
return one < two
})
let sortedString5 = animals.sort({one, two in
one < two
})
let sortedString6 = animals.sort({$0 < $1})
let sortedString7 = animals.sort(){$0 < $1}
print(sortedString7)
let sortedString8 = animals.sort{$0 < $1}
print(sortedString8)
let sortedString9 = animals.sort(>)
print(sortedString9)
typealias stateMachineType = () ->Int
func makeStateMachine(maxState: Int) -> stateMachineType{
var currentState: Int = 0
return{
currentState++
if currentState > maxState{
currentState = 0
}
return currentState
}
}
let tt = makeStateMachine(2)
print(tt())
print(tt())
print(tt())
print(tt())
print(tt())