0
 Map<String,Set<String>> st= new Map<String,Set<String>>();
st.put('one',new Set<String>{'1','2'});
 Set<string> ss = new Set<String>();
 ss.addAll(st.values());//Error. I think we should iterate and add to set one by on. any Idea to get all at once (like any addAll..)
system.debug(ss);

any shortcut to get set from map> ? But it return

list<set<string>>()

1 Answer 1

7

You have to loop through and use addAll. There is no shortcut.

Set<String> allValues = new Set<String>();
for (Set<String> subset : st.values())
{
    allValues.addAll(subset);
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .