Guest User

Untitled

a guest
Feb 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. func swap<T>(item1: inout T, item2: inout T)
  2. {
  3. let tmp = item1
  4. item1 = item2
  5. item2 = tmp
  6. }
  7.  
  8. var name: String = "Kerem", surname: String = "Vatandas"
  9. swap(&name, &surname)
  10. print("isim: \(name), soyisim: \(surname)") // "isim: Vatandas, soyisim: Kerem\n"
  11.  
  12. var no1: Int = 99, no2: Int = 33
  13. swap(&no1, &no2)
  14. print("no1: \(no1), no2: \(no1)") // "no1: 33, no2: 33\n"
  15.  
  16.  
  17. var dNo1: Double = 12.3, dNo2: Double = 20.5
  18. swap(&dNo1, &dNo2)
  19. print("dNo1 = \(dNo1), dNo2 = \(dNo2)") // "dNo1 = 20.5, dNo2 = 12.3\n"
Add Comment
Please, Sign In to add comment