Created
November 27, 2019 14:59
-
-
Save cyrilchampier/2ff05ffd1ed276f024c1f6cbff91d668 to your computer and use it in GitHub Desktop.
extend == singleton include
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# extend == include in singleton class | |
module Mincluded | |
def toto | |
puts 'Mincluded#toto' | |
end | |
end | |
module MSingletonIncluded | |
def toto | |
puts 'MSingletonIncluded#toto' | |
end | |
end | |
module MExtended | |
def toto | |
puts 'MExtended#toto' | |
end | |
end | |
class A | |
include Mincluded | |
extend MExtended | |
class << self | |
include MSingletonIncluded | |
end | |
end | |
A.ancestors | |
A.singleton_class.ancestors | |
A.toto | |
A.new.toto | |
def A.new.pouet | |
puts 'pouet' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment