For example we have:
module X
def test
"X"
end
end
module Y
def test
"Y"
end
end
class L
include X
end
L.new.test #=> "X"
class L
include Y
end
L.new.test #=> "Y"
class L
include X
end
L.new.test #=> "Y"
Here’s the strange thing. Why the last include didn’t change the method to X’s method?
Ruby does not allow to include one module twice, attempt to do it second time is just ignored.
From documentation of Module#append_features which is used by
Module#includeunder the covers: