blob: db5d7a97c2fbef4c372a61b22a673a4a7055c6f4 [file] [log] [blame]
/**
* Sample code using the experimental Swift 3 runtime
* A word count utility
* @param payload A string of words to count.
*/
func main(args: [String:Any]) -> [String:Any] {
if let str = args["payload"] as? String {
let words = str.components(separatedBy: " ")
let count = words.count
print("The message '\(str)' has \(count) words")
return ["count": count]
} else {
return ["error": "You must specify a payload parameter!"]
}
}