timyc
timyc

Reputation: 35

How to add a prefix to every element of a set in Dart?

I initialize a set as

Set<String> ids = <String>{'1','2','3','4','5'};

How can I add a prefix such as ios_ to the set of ids such that the result is

Set<String> ids = <String>{'ios_1','ios_2','ios_3','ios_4','ios_5'};

Upvotes: 1

Views: 433

Answers (1)

jmvcollaborator
jmvcollaborator

Reputation: 2475

You can use map() :

var result = ids.map((val) => 'ios_$val').toSet();

Upvotes: 1

Related Questions