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

List.toSet

toSet() -> map

Description

Create a Map where every item in the original list is a key, assigned to true.

This transforms it into something like a mathematical set, where each value (Map key) is unique.

$letters = ['a', 'a', 'b', 'z', 'z']

$set = $letters.toSet()
//= { 'a': true, 'b': true, 'z': true }

if $set['z'] { ... }

See Also