Created
July 13, 2015 05:38
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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