From: ruby-core@... Date: 2015-08-09T06:31:56+00:00 Subject: [ruby-core:70278] [Ruby trunk - Bug #11422] [Rejected] All common set operations produce incorrect (and surprising) results on a set of sets Issue #11422 has been updated by Marc-Andre Lafortune. Status changed from Open to Rejected This is as per spec, a set of sets is not the same as the union of those sets. You may want to use `abc = ab + c` instead of `abc = Set.new([ab, c])`? ---------------------------------------- Bug #11422: All common set operations produce incorrect (and surprising) results on a set of sets https://bugs.ruby-lang.org/issues/11422#change-53702 * Author: Peter Hillerstr��m * Status: Rejected * Priority: Normal * Assignee: * ruby -v: 2.2.2 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- # Set operations on a set of sets produce incorrect results It seems that almost all common set operations (subtract, superset?, subset?, difference, etc...) produce (mathematically) incorrect results on a set of sets, in that they just return the set of sets unmodified. The union, intersection, and exclusion operations produce even weirder results, even when both parameters are sets of sets ��� some members of the result are scalar values and some are sets. ```ruby 2.2.2 :119 > ab = Set.new(['A', 'B']) => # 2.2.2 :120 > c = Set.new(['C']) => # 2.2.2 :121 > abc = Set.new([ab, c]) ``` ## Substraction fails ```ruby 2.2.2 :122 > abc - c => #, #}> ``` ## Superset fails ```ruby 2.2.2 :140 > abc > ab => false ``` See [more examples](http://pastie.org/10337538#18) on pastie.org. Python just throws `TypeError: unhashable type: 'set'`. -- https://bugs.ruby-lang.org/