Skip to content

Instantly share code, notes, and snippets.

@jweinst1
Created July 13, 2015 19:09
Show Gist options
  • Save jweinst1/451bb50245f7767d0d25 to your computer and use it in GitHub Desktop.
Save jweinst1/451bb50245f7767d0d25 to your computer and use it in GitHub Desktop.
Function that can determine whether or not to add a character to a string based on some of the indexes of the string. Swift.
func indexstring(str: String, index: Int) ->Character {
var strlist = Array(str)
return strlist[index]
}
func addconorvow(str: String) ->String {
var modstr = str
if indexstring(str, 1) == "d" {
modstr += "d"
return modstr
} else {
modstr += "e"
return modstr
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment