本页尚未翻译,因此以英文显示。 参与翻译

values

The values of a Map, as a plain lazy Iterable — ready to wrap in fx() and chain.

Iterable<V> values<K, V>(Map<K, V> map)

Lecture

values(map) is keys's twin: a thin wrapper around Dart's map.values, given a name consistent with the rest of the object-function vocabulary so it reads naturally as fx(values(map)) next to fx(keys(map)) and fx(entries(map)). Like map.values itself, it's already a lazy view — no extra buffering happens.

Because it hands back a plain Iterable<V>, every chain operator you've learned so far applies directly — including the numeric terminals (sum(), average(), min(), max()) when V is a num. This makes values the natural entry point for aggregating a Map's data: total up prices, average scores, find the newest timestamp, and so on.

This is also the last stop before map itself — the next lesson, and the operator you'll reach for constantly from here on to reshape whatever values, entries, or any other source hands you.

Demo 1 · Basics

Demo 2 · Aggregating a Map's values

Try it yourself

Exercise: use values to compute the average score.

Related: keys — the keys of a Map · entries — keys and values paired together · map — reshape every value in a chain · sum · average · min · max — the numeric terminals used above