Core & membership ready
Insertion-ordered storage with add / add?, delete / delete?, include?, size, empty?, clear, each, to_a, dup, merge and subtract โ keyed by member identity or through the host Hasher.
Ruby's Set โ the unordered, unique collection with full set algebra โ in pure Go, no cgo.
Set
set algebra | & - ^
subset ยท superset ยท disjoint
classify ยท divide ยท group_by
insertion-ordered
Hasher seam
MRI byte-exact
100% coverage
6 archesgo-ruby-set is a pure-Go (no cgo) reimplementation of Ruby's Set โ the unordered, unique collection with full set algebra from MRI's set standard library (autoloaded core in Ruby 4.0). It mirrors Set's observable behaviour: insertion-ordered iteration, add? / delete?, the | & - ^ operators, subset / superset / disjoint predicates, and classify / divide / group_by / flatten โ without any Ruby runtime. Element identity is supplied by the host through a Hasher seam, exactly as MRI keys members by hash / eql?. It is a standalone, reusable module โ the Set backend bound into go-embedded-ruby by rbgo, the same pattern as go-ruby-yaml โ differential-tested against MRI, 100% coverage, CI green across 6 arches and 3 OSes.
Insertion-ordered storage with add / add?, delete / delete?, include?, size, empty?, clear, each, to_a, dup, merge and subtract โ keyed by member identity or through the host Hasher.
Union (|/+), Intersection (&), Difference (-) and XorSym (^) โ the four operators producing fresh sets that preserve first-insertion order.
subset? / <=, proper_subset? / <, superset? / >=, proper_superset? / >, disjoint?, intersect? and ==, matching MRI’s comparison semantics exactly.
map / collect, select / reject, in-place collect!, plus classify, group_by, both divide forms, recursive flatten, and sort via SortedSlice.
A pluggable Hasher maps a member to the comparable Go key under which two members coincide โ rbgo plugs Ruby’s hash / eql?; plain New keys members by themselves.
Set algebra, predicates, classify, both divide forms and the Set[โฆ] inspect computed here and checked byte-for-byte against the system ruby (gated on Ruby โฅ 4.0); 100% coverage, gofmt + go vet clean, green across 6 arches and 3 OSes.
A faithful pure-Go port of Ruby's `Set`, cgo disabled, so it cross-compiles and embeds anywhere. Validated differentially against the system ruby binary, byte-for-byte. It is a standalone, reusable module extracted from rbgo's internals, and the backend bound by rbgo into the sibling org github.com/go-embedded-ruby.