Created
March 29, 2018 09:10
-
-
Save ahti/26e28a3df00b5f1e536939459c16afc5 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
struct Property<T> { | |
let name: String | |
} | |
extension Property { | |
static var someBool: Property<Bool> { return Property<Bool>(name: "bool") } | |
static var someString: Property<String> { return Property<String>(name: "lol") } | |
} | |
struct Foo { | |
static func valueFor<T>(_ prop: Property<T>) -> T { | |
switch prop.name { | |
case "bool": return true as! T | |
case "lol": return "hi" as! T | |
default: fatalError() | |
} | |
} | |
} | |
let s = Foo.valueFor(.someString) | |
let b = Foo.valueFor(.someBool) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment