summaryrefslogtreecommitdiff
path: root/st.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-15 13:52:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-15 13:52:38 +0000
commit10d85b19da5a9c94c5e7af16c53679981aee963b (patch)
tree734e2fd52602f34fb9d6f58747718325f4a49bf9 /st.c
parentd7976d145193379d8c43f33e9a5714292a40d994 (diff)
Clarify Array#- and Array#difference documentation
Currently we are not explicit enough regarding the potentially confusing behavior of `Array#-` and `Array#difference` when it comes to duplicate items within receiver arrays. Although the original documentation for these methods does use an array with multiple instance of the same integers, the explanation for the behavior is actually imprecise. > removing any items that also appear in +other_ary+ Not only does `Array#-` remove any items that also appear in `other_ary` but it also remove any instance of any item in `other_ary`. One may expect `Array#-` to behave like mathematical subtraction or difference when it doesn't. One could be forgiven to expect the following behavior: ```ruby [1,1,2,2,3,3,4,4] - [1,2,3,4] => [1,2,3,4] ``` In reality this is the result: ```ruby [1,1,2,2,3,3,4,4] - [1,2,3,4] => [] ``` I hope that I've prevented this potential confusion with the clarifications in this change. I can offer this as evidence of likeliness for confusion: https://twitter.com/olivierlacan/status/1084930269533085696 I'll freely admit I was surprised by this behavior myself since I needed to obtain an Array with only one instance of each item in the argument array removed. [Fix GH-2068] [ci skip] From: Olivier Lacan <hi@olivierlacan.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'st.c')
0 files changed, 0 insertions, 0 deletions