Last active
October 31, 2015 23:32
-
-
Save EDmitry/59878486f0a6b4e9ed8c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: 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