From: ruby-core@... Date: 2017-11-29T16:40:31+00:00 Subject: [ruby-core:83976] [Ruby trunk Bug#12834] `prepend` getting prepended even if it already exists in the ancestors chain Issue #12834 has been updated by marcandre (Marc-Andre Lafortune). shyouhei (Shyouhei Urabe) wrote: > Thus, matz started thinking that if a module is prepended multiple times, that should appear more than once in a method chain. Could you clarify? For inclusion/prepending, there are two questions in my mind: 1) what happens if a module is included/prepended multiple times at different places in the hierarchy (e.g. in A and B, in the example above) 2) what happens if it is included/prepended multiple times at the same level (e.g. twice in A) Was the discussion about (b) allowing multiple times at the same level? ---------------------------------------- Bug #12834: `prepend` getting prepended even if it already exists in the ancestors chain https://bugs.ruby-lang.org/issues/12834#change-68056 * Author: ndn (Nikola Nenkov) * Status: Open * Priority: Normal * Assignee: * Target version: * ruby -v: 2.3.1 * Backport: 2.3: UNKNOWN ---------------------------------------- ``` module M; end class A; prepend M; end class B < A; prepend M; end B.ancestors # => [M, B, M, A, Object, Kernel, BasicObject] ``` Even though I find this behaviour to be more intuitive, it is inconsistent with `Module#include` and is potentially breaking. I didn't see a mention on the [[release notes]](https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/) and the [[documentation]](https://ruby-doc.org/core-2.3.1/Module.html#method-i-prepend_features) is now outdated. -- https://bugs.ruby-lang.org/ Unsubscribe: