Issue #13102 has been updated by jeremyevans0 (Jeremy Evans). Eregon (Benoit Daloze) wrote: > This is at least inconsistent with Array#delete, which could be used for the same case as above but doesn't end with a `?`. This is not exactly true, as `Set#delete?` returns self and not the item if deleted: ```ruby require 'set' set = Set[true, false] p(set.delete?(false) ? 1 : 0) # => 1 p(set.delete?(false) ? 1 : 0) # => 0 array = [true, false] p(array.delete(false) ? 1 : 0) # => 0 p(array.delete(false) ? 1 : 0) # => 0 ``` > I don't think there are many good examples for predicates with side effects, is it? No, there aren't a lot of good examples. I don't think there are any examples in core, and I'm not sure about the rest of stdlib. > A good part of the Set API is quite inconsistent with the rest, unfortunately (e.g., Set#merge being inplace). > Maybe we could slowly deprecate these inconsistent methods and align the API with Array and Hash? We could definitely do that, but that is a feature request, not a bug report. ---------------------------------------- Bug #13102: Confusing method name: Set#delete? https://bugs.ruby-lang.org/issues/13102#change-80973 * Author: kaikuchn (Kai Kuchenbecker) * Status: Rejected * Priority: Normal * Assignee: * Target version: * ruby -v: 2.4.0 * Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN ---------------------------------------- Greetings, a colleague of mine who recently started to learn Ruby managed to greatly confuse me today when he used Set#delete? which he claimed would delete an item from a set. Reading the documentation I suspect the method was meant to be named delete! as it behaves similiar to Array#uniq! and such methods. If this is not a mistake, I'd still suggest to change the method name since I think it is very surprising for a method ending in a question mark to have a side effect. Best regards, Kai -- https://bugs.ruby-lang.org/ Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>