Last active
January 19, 2016 04:56
-
-
Save Pearapps/a367fa51c059019be4b1 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 | |
func makeView<ViewType: UIView>(f: () -> ViewType, translatesAutoresizingMaskIntoConstraints: Bool) -> ViewType { | |
let view = f() | |
view.translatesAutoresizingMaskIntoConstraints = translatesAutoresizingMaskIntoConstraints | |
return view | |
} | |
final class MyView: UIView { | |
init(string: String) { | |
super.init(frame: CGRectZero) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
fatalError("init(coder:) has not been implemented") | |
} | |
} | |
func un<A, B>(f : A -> B, a: A) -> () -> B { | |
return { | |
f(a) | |
} | |
} | |
let view: MyView = makeView(un(MyView.init, a: "String that goes into initializer"), translatesAutoresizingMaskIntoConstraints: true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment