Created
February 12, 2012 20:16
-
-
Save cadwallion/1810692 to your computer and use it in GitHub Desktop.
Namespace derivation problem
This file contains hidden or 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
# EXPECTED OUTPUT | |
a = Foo::Bar.new | |
b = AnotherFoo::AnotherBar.new | |
a.thing # => [1,2,3,4] | |
b.thing # => [5,6,7,8] |
This file contains hidden or 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
class Foo | |
def self.thing | |
[1,2] | |
end | |
class Bar < ::Baz | |
def initialize | |
@data = [3,4] | |
end | |
end | |
end | |
class AnotherFoo | |
def self.thing | |
[5,6] | |
end | |
class AnotherBar < ::Baz | |
def initialize | |
@data = [7,8] | |
end | |
end | |
end | |
class Baz | |
def thing | |
more_data = @data | |
# THIS NEEDS TO COMBINE more_data with its corresponding Foo#thing or AnotherFoo#thing depending upon the immediate namespace of the class | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment