How to insert a character in a string at specific index with Swift

1 Answer

0 votes
var str = "Swift Java C++"

str.insert("y", at : str.index(str.startIndex, offsetBy: 9))

print(str)




/*
run:
  
Swift Javya C++
  
*/

 



answered Jun 11, 2023 by avibootz

Related questions

1 answer 128 views
1 answer 223 views
1 answer 149 views
1 answer 135 views
1 answer 239 views
1 answer 214 views
...