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 135 views
1 answer 232 views
1 answer 152 views
1 answer 138 views
1 answer 249 views
1 answer 224 views
...