Reputation: 7
List<String> pisah = ['saya','sedang','belajar','menjadi','programmer','yang','handal','dan','menyenangkan'];
How can I make that list so that I can print just every first letter of the word example like :
baris 1 : S S B M P Y H D M
Upvotes: 1
Views: 303
Reputation: 34282
That's all in a day's work for the method map
.
final letters = pisah.map((s) => s[0]).toList();
print(letters);
The .toList()
call may or may not be needed depending on what exactly you want to do with the result. For example, it can be omitted if you want only to iterate over it, but it's required if you need to access individual letters using letter[i]
.
Upvotes: 1