ruby / set

This library provides the Set class, which deals with a collection of unordered values with no duplicates.
BSD 2-Clause "Simplified" License
23 stars 13 forks source link

Add `Set#<=>` #5

Closed marcandre closed 3 years ago

marcandre commented 3 years ago

It compares only Sets. Other classes (in particular array) can not be compared and nil is returned.

The implementation of <, >, subset?, etc., could all depend on <=>, but it is more efficient to keep them as is. a < b can return false without having to know the reason (is it that a > b or do they both have distinct elements).