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 115 views
1 answer 211 views
1 answer 142 views
1 answer 129 views
1 answer 230 views
1 answer 199 views
...