This file contains hidden or 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
import UIKit | |
class A : CustomDebugStringConvertible | |
{ | |
let message: String | |
required init( message: String ) { self.message = message } | |
var debugDescription: String { return message } | |
} |
This file contains hidden or 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
protocol ProtocolA {} | |
protocol ProtocolB {} | |
func overloadingTest ( obj: String ) -> String | |
{ | |
return "It's a String" | |
} | |
func overloadingTest ( obj: Int ) -> String // This compiles fine, and the appropriate 'topLevelTest' function is called |
This file contains hidden or 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
protocol ProtocolA {} | |
protocol ProtocolB {} | |
func overloadingTest <T where T: ProtocolA>( obj: T ) -> String | |
{ | |
return "It's an implementation of Protocol A" | |
} | |
func overloadingTest <T where T: ProtocolB>( obj: T ) -> String // This compiles fine, and the appropriate 'topLevelTest' function is bound |
This file contains hidden or 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
class A<SelfType : A<SelfType>> | |
{ | |
} | |
class B : A<B> // Line fails to compile with: "'A' requires that 'B' inherit from 'A<B>'" even though it does | |
{ | |
} |
This file contains hidden or 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
protocol MyProtocol | |
{ | |
typealias GenType | |
func doSomething(param: GenType) | |
} | |
class MyObject<T> : MyProtocol | |
{ | |
typealias GenType = T |
NewerOlder