Version: v0.8.1 - Beta.  We welcome contributors & feedback.

List.toMap

toMap($keys=auto) -> map

Description

Create a map where every item in the original List is assigned a key.

The first list item is assigned to the first item of $keys, and so on.

The number of keys and values must be identical.

If $keys is not defined, it will use the index of each List item instead (1, 2, 3, ...).

$keys = ['name', 'job', 'age']
$values = ['Tashi', 'Teacher', 33]

$values.toMap($keys)
//= { name: 'Tashi', job: 'Teacher', age: 33 }


['a', 'b', 'c'].toMap()
//= { 1: 'a', 2: 'b', 3: 'c' }

See Also