Created
May 23, 2019 04:42
-
-
Save wotjd/b94afd2ca7dec67b4d94fddcd078d372 to your computer and use it in GitHub Desktop.
swift block scope idea for test (protocol not allowed)
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 Foundation | |
public func FuntionScope(_ closure: () -> () ) { | |
closure() | |
} | |
public let TupleScope = { (c: () -> ()) in c() } | |
public let TupleExpScope: (() -> ()) -> () = { $0() } | |
// adding closure typealias | |
public typealias Closure<T> = (T) -> Void | |
public let TupleExpScopeWithTypealias: Closure<Closure<Void>> = { $0(()) } | |
public let scope = TupleExpScopeWithVoidTypealias | |
// usage | |
scope { | |
print("hi there?") | |
print("hello? i'm in here") | |
print("good") | |
} | |
// error | |
scope { | |
protocol AProtocol { ... } // Protocol 'AProtocol' cannot be nested inside another declaration | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment