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 |
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 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
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
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
// | |
// HTTPStatus.swift | |
// | |
// Created by Chris Hatton on 17/05/2016. | |
// | |
// Transcribed from: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes | |
// | |
import Foundation |
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
using System; | |
using System.Collections; | |
using UnityEngine; | |
/* | |
* Use by explicit 'this' e.g. this.Invoke( 3.0f, delegate { doSomething(); } ); | |
*/ | |
static class MonoBehaviourInvokeExtension | |
{ | |
public static void Invoke( this MonoBehaviour monoBehaviour, float delay, Action action ) |
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 | |
protocol HTTPRequest | |
{ | |
associatedtype ResultType | |
func start( callback: (ResultType)->() ) | |
} |
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
// This compiles in both Swift 2 and 3 | |
func test1() -> Int { | |
fatalError() | |
} | |
// This compiled in Swift2 but no longer does in Swift 3 | |
let test2 : () -> Int = { | |
fatalError() | |
} |
OlderNewer