Advertisement
Guest User

Untitled

a guest
Oct 8th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. struct SA<T> {
  3. let v: T
  4. init(_ v: T) { self.v = v }
  5. }
  6.  
  7. typealias SB = SA<(Int, Int)>
  8. typealias SC = SA<W>
  9. typealias W = (Int, Int)
  10.  
  11. struct SD {
  12. let v: (Int, Int)
  13. init(_ v: (Int, Int)) { self.v = v }
  14. }
  15.  
  16. let a = SA(1, 2) // Works with zero or more parens around 1, 2 (not counting arg list parens).
  17. let b = SB(1, 2) // Works _only_ with zero parens.
  18. let c = SC((1, 2)) // Works with with one or more parens.
  19. let d = SD((1, 2)) // Works with with one or more parens.
  20.  
  21. // To me, the types of a, b, c and d are as similar as different types can be.
  22. // Yet they are very different in the way they can be initialized, why?
  23. // How come SB and SC must be initialized differently for example?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement