Advertisement
Guest User

Untitled

a guest
Oct 29th, 2019
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.34 KB | None | 0 0
  1. import Foundation
  2.  
  3. @inline(never)
  4. func makeFunc(_ x: Int) -> () -> Void {
  5.     if arc4random() & 1 == 0 {
  6.         return { print(x + 1) }
  7.     } else {
  8.         return { print(x - 1) }
  9.     }
  10. }
  11.  
  12. func test() {
  13.     let funcs = [makeFunc(1), makeFunc(2), makeFunc(3), makeFunc(4), makeFunc(5), makeFunc(6)]
  14.     print(funcs)
  15. }
  16.  
  17. test()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement