# Sets

## Sets

Sets are an unordered collection of unique hashable values. Set values must be of type string, number, boolean or nil.

``````var mySet = set("test", 10);
print(mySet); // {10, "test"}
``````

### set.toString()

Converts a given set to a string.

``````var set_a = set();

var set_b = set();

set_a.toString(); // '{"two", "one"}');
set_b.toString(); // '{2, 1}'
``````

### set.toBool()

Converts a set to a boolean. A set is a “truthy” value when it has a length greater than 0.

``````var x = set();

x.toBool(); // false
x.toBool(); // true
``````

### set.len()

Returns the length of the given set.

``````var mySet = set();
mySet.len(); // 1
``````

Adding to sets is just a case of passing a value to .add()

``````var mySet = set();
``````

### set.contains(value)

To check if a set contains a value use `.contains()`

``````var mySet = set();
print(mySet.contains("Dictu!")); // true
print(mySet.contains("Other!")); // false
``````

### set.remove(value)

To remove a value from a set use `.remove()`.

Note: If you try to remove a value that does not exist a runtime error is raised, use together with `.contains()`.

``````var mySet = set();