Reputation: 151076
The following code runs perfectly if it is in a standalone command line app:
extension Int {
func sayHello() {
println("Hello, I'm \(self)")
}
}
1.sayHello()
2.sayHello()
However, in playground, it won't run, and the error is "(2 times)". Can we not extend a class in playground or how do we do it?
Upvotes: 2
Views: 704
Reputation: 66282
A few corrections:
Int
is a struct (value type), not a classYou can click the eye icon to see the output:
Upvotes: 1