struct

Set(T)

Inherits Iterable / Enumerable / Struct / Value / Object

Set implements a collection of values with no duplicates.

An Enumerable object can be converted to Set using the #to_set method.

Set uses Hash as storage, so you must note the following points:

  • Equality of elements is determined according to Object#== and Object#hash.
  • Enumeration follows the order that the elements were inserted.
  • Set assumes that the identity of each element does not change while it is stored. Modifying an element of a set will render the set to an unreliable state.

Example

s1 = Set{1, 2}
s2 = [1, 2].to_set
s3 = Set.new [1, 2]
s1 == s2 # => true
s1 == s3 # => true
s1.add(2)
s1.concat([6, 8])
s1.subset_of? s2 # => false
s2.subset_of? s1 # => true

Instance methods

to_hcl(builder : HCL::Builder)

Returns HCL list representation of Set

Source