How to get first letter of each word in a string with Swift

1 Answer

0 votes
import Foundation

let s = "swift python c++ java rust"

for word in s.split(separator: " ") {
    print(word[word.startIndex])
}



/*
run:

s
p
c
j
r

*/

 



answered Nov 1, 2024 by avibootz
...