Skip to content

Instantly share code, notes, and snippets.

@jakehawken
Created October 16, 2018 19:49
Show Gist options
  • Select an option

  • Save jakehawken/a3f447b3529e0a0158f4efa862acfafc to your computer and use it in GitHub Desktop.

Select an option

Save jakehawken/a3f447b3529e0a0158f4efa862acfafc to your computer and use it in GitHub Desktop.
static func -=(lhs: inout String, rhs: String) {
guard lhs.hasSuffix(rhs) else {
return
}
guard let range = lhs.range(of: rhs, options: [.backwards], range: nil, locale: nil) else {
return
}
lhs = lhs.replacingCharacters(in: range, with: "")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment