struct Set(T)
Overview
Set implements a collection of unordered 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#==andObject#hash. Setassumes 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
Included Modules
- Enumerable(T)
- Iterable(T)
Defined in:
to_con.crInstance Method Summary
Instance methods inherited from struct Value
==(other : CON::Any)
==
Instance methods inherited from class Object
===(other : CON::Any)
===,
from_con(con : String | IO)
from_con,
to_con(io : IO)to_con to_con, to_pretty_con(indent : String = " ")
to_pretty_con(io : IO, indent : String = " ") to_pretty_con