How to remove the first character from string in Swift

4 Answers

0 votes
let s = "Swift Programming"

let substring = s[s.index(s.startIndex, offsetBy: 1)..<s.endIndex]

print(substring)




/*
run:

wift Programming

*/

 



answered Nov 10, 2020 by avibootz
0 votes
var s = "Swift Programming"

s = String(s[s.index(s.startIndex, offsetBy: 1)..<s.endIndex])

print(s)




/*
run:

wift Programming

*/

 



answered Nov 10, 2020 by avibootz
0 votes
var s = "Swift Programming"

s.remove(at: s.startIndex)

print(s)




/*
run:

wift Programming

*/

 



answered Nov 10, 2020 by avibootz
0 votes
var s = "swift java c++ c python"
 
s = String(s.dropFirst(1))
 
print(s)
  
  
  
   
/*
run:
 
wift java c++ c python
   
*/

 



answered Nov 10, 2020 by avibootz

Related questions

1 answer 177 views
1 answer 100 views
1 answer 251 views
2 answers 240 views
1 answer 105 views
1 answer 199 views
1 answer 196 views
...