Skip to content

Instantly share code, notes, and snippets.

@froggomad
Last active June 4, 2020 15:37
Show Gist options
  • Save froggomad/26a1b9dfd620b87aff2e586005d91989 to your computer and use it in GitHub Desktop.
Save froggomad/26a1b9dfd620b87aff2e586005d91989 to your computer and use it in GitHub Desktop.
firstTwoChars = * and lastTwoChars = *
// Created by Kenny Dubroff on 10/14/18.
var str = "p123869"
var chars = Array(str)
//first 2 characters are always 0 and 1
chars[0] = "*"
chars [1] = "*"
///endIndex is always one greater than the last index
let endIndex = chars.endIndex - 1
let nextToEndIndex = endIndex - 1
chars[endIndex] = "*"
chars[nextToEndIndex] = "*"
print(chars) //**238**
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment