Skip to content

Instantly share code, notes, and snippets.

@jweinst1
Created July 13, 2015 05:38
Show Gist options
  • Save jweinst1/f4b289f35245ed99cd43 to your computer and use it in GitHub Desktop.
Save jweinst1/f4b289f35245ed99cd43 to your computer and use it in GitHub Desktop.
In Swift, this script uses the last() function to check if the inputted character is equal to the last character in a string.
var str = "Hello, playground"
func checklastletter(word: String, letter: String) ->String {
if letter == last(word) {
return true
} else {
return false
}
}
checklastletter(str, "g")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment