Updated to Xcode 6.3.1 with new Swift 1.2, the old method countElement
change to count
, however when I switch to use count
, it always throw out this error message:
cannot invoke 'count' with an argument list of type '(String)'
This snippet is I copied from Apple doc, but still not working.
func printAndCount(stringToPrint: String) -> Int {
println(stringToPrint)
return count(stringToPrint)
}
func printWithoutCounting(stringToPrint: String) {
printAndCount(stringToPrint)
}
printAndCount("hello, world")