Reputation: 5421
I am certain I am missing something very, very obvious, but can anyone tell me why I am having trouble multiplying two Integers
? The following code:
let twenty: Integer = 20
let ten: Integer = 10
let result: Integer = twenty * ten
presents the error Could not find an overload for '*' that accepts the supplied arguments
.
Other questions on SO with the same error are caused by trying to multiply different types together, but surely these are both Integer
types?
(PS: The actual code I am trying to run is var value = self.value * 10
but I have expanded it to the sample while debugging to make absolutely sure that the correct types are being used)
Upvotes: 1
Views: 7499
Reputation: 15335
As already stated , Integer is a protocol not a type .
In your situation, you don't need to do explicit the type because it is of implicit casting.
This could be enough
let twenty = 20
let ten = 10
let result = twenty * ten
NSLog("%d", result)
Upvotes: 1