Skip to content

Instantly share code, notes, and snippets.

@clarkeben
Last active September 14, 2023 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkeben/facf50d0a2d82ab80f91e4c6e0d71870 to your computer and use it in GitHub Desktop.
Save clarkeben/facf50d0a2d82ab80f91e4c6e0d71870 to your computer and use it in GitHub Desktop.
subtrings-swift
let str = "Apple"
let index = str.index(str.startIndex, offsetBy: 3)
let mySubstring = str.prefix(upTo: index)
let str = "Apple"
let index = str.index(str.startIndex, offsetBy: 3)
let mySubstring = str.prefix(upTo: index)
let substringToString = String(mySubstring) //App
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment