Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class C {
- lazy var x: () -> Void = {
- return { print("hi") }
- }()
- lazy var y: (Int) -> Void = { // `input in` shouldn't be written here!
- return { input in
- print(input)
- }
- }()
- var r: () -> Void = {
- return { print("hi") }
- }()
- let t: () -> Void = {
- return { print("bye") }
- }()
- let yy: (Int) -> Void = { // `input in` shouldn't be written here!
- return { input in
- print(input)
- }
- }()
- }
- let c = C()
- let k = c.x
- print(k) // (Function)
- k() // hi
- c.x() // hi
- c.y(5) // hi
- c.r()
- c.r = c.t
- print("new")
- c.r
- c.yy(10)
- c.yy(15) // Can pass different arguemnt
- c.t = c.r // Can't change the actual closure itself. It's a let. Needs to be changed to `var`
- c.t()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement