Logo

Programming-Idioms

Create the list k containing all the keys of the map m
New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating material.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
final k = m.keys;
import "golang.org/x/exp/maps"
k := maps.Keys(m)
k := make([]K, 0, len(m))
for key := range m {
	k = append(k, key)
}
import java.util.ArrayList;
import java.util.List;
List<K> k = new ArrayList<>(m.keySet());
import static java.util.List.copyOf;
import java.util.List;
List<K> k = copyOf(m.keySet());
@k = keys %m;
k = m.keys()
k = [*m.keys()]
k = list(m.keys())
k = m.keys
use std::collections::HashMap;
m.keys().collect::<Vec<_>>()