Reputation: 3
Playground execution failed: MyPlayground.playground:19:33: error: cannot find an initializer for type 'Int' that accepts an argument list of type '(String)' var languagesLearnedNum: Int? = Int(languagesLearned) ^
var languagesLearned: String = "3"
var languagesLearnedNum: Int? = Int(languagesLearned)
if let num = languagesLearnedNum {
println("It is a Number")
}else {
println("It is not a Number")
}
Upvotes: 0
Views: 131
Reputation: 2107
Use languagesLearned.toInt()
. However, you're not using Swift 2.0 as if you were, you would be able to use Int(languagesLearned)
but not println()
.
Upvotes: 1