Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. let s = "Café du 🌍"
  2.  
  3. let si = s.startIndex
  4. let ci = s.characters.startIndex
  5. si == ci // true
  6.  
  7. let si2 = s.index(si, offsetBy: 3)
  8. let ci2 = s.characters.index(ci, offsetBy: 3)
  9. si2 == ci2 // true
  10.  
  11. let si3 = s.index(after: si2)
  12. let ci3 = s.characters.index(after: ci2)
  13. si3 == ci3 // true
  14.  
  15. let e1 = s[si2..<si3] // é
  16. let e2 = s[ci2..<ci3] // é
  17. let e3 = String(s.characters[si2..<si3]) // é
  18. let e4 = String(s.characters[ci2..<ci3]) // é
  19.  
  20. e1 == e2 // true
  21. e1 == e3 // true
  22. e1 == e4 // true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement