How to remove the first six characters from a string in Swift

2 Answers

0 votes
var s = "swift java c++ c python"
 
s.removeSubrange(s.startIndex..<s.index(s.startIndex, offsetBy: 6))
 
print(s)
  
  
  
   
/*
run:
 
java c++ c python
   
*/

 



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

 



answered Nov 10, 2020 by avibootz

Related questions

1 answer 186 views
2 answers 181 views
1 answer 189 views
1 answer 180 views
1 answer 179 views
...