ios - 'advance' keyword in swift? -
let word = "sample string" let firstletter = character(word.substringtoindex(advance(word.startindex,1)).uppercasestring)
i got above example tutorial. can know mean "advance" , difference between "substringtoindex" , "substringwithrange".
this advance
syntax swift 1, it's different now.
swift 2
let firstletter = character(word.substringtoindex(word.startindex.advancedby(1)).uppercasestring)
the advancedby
method moves current index along string.
with substringtoindex
slice part of string, beginning @ start of string , ending @ index defined advancedby
.
here advance 1 in string, means substringtoindex
first character string.
swift 3
the syntax has changed again, use substring
, index
offset:
let firstletter = character(word.substring(to: word.index(word.startindex, offsetby: 1)).uppercased())
Comments
Post a Comment