Skip to content

Instantly share code, notes, and snippets.

@EDmitry
Last active October 31, 2015 23:32
Show Gist options
  • Save EDmitry/59878486f0a6b4e9ed8c to your computer and use it in GitHub Desktop.
Save EDmitry/59878486f0a6b4e9ed8c to your computer and use it in GitHub Desktop.
//: Playground - noun: a place where people can play
import UIKit
protocol Incable {
func inc () -> Incable
}
class DoubleWrapper : Incable {
let number: Double
init(number: Double) {
self.number = number
}
func inc() -> Incable {
return DoubleWrapper(number: self.number + 1)
}
}
class IntWrapper : Incable {
let number: Int
init(number: Int) {
self.number = number
}
func inc() -> Incable {
return IntWrapper(number: self.number + 1)
}
}
func incer (incable: Incable) -> Incable {
return incable.inc()
}
func inctuple(incingfunc: (Incable) -> Incable) -> (DoubleWrapper, IntWrapper) {
// Error: Cannot convert return expression of type (Incable, Incable)
// to return type (DoubleWrapper, IntWrapper)
return (incingfunc(DoubleWrapper(1.5)), incingfunc(IntWrapper(5)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment