Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #330 Map to list

Create the list a containing all the values of the map m.

Ignore the keys of m. The order of a doesn't matter. a may contain duplicate values.

a = [*m.values()]
a = list(m.values())
using System.Linq;
var a = m.Values.ToList();
a = Map.values(m)
a := make([]V, 0, len(m))
for _, v := range m {
	a = append(a, v)
}
import "golang.org/x/exp/maps"
a := maps.Values(m)
@a = values %m;
a = m.values
use std::collections::HashMap;
let a = m.into_values().collect::<Vec<_>>();

New implementation...
< >
programming-idioms.org