Created
March 27, 2016 14:11
-
-
Save lokeshh/1d6b5686dcb5e90d97e0 to your computer and use it in GitHub Desktop.
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
module CategoricalData | |
def size | |
20 | |
end | |
end | |
class Vector | |
def initialize type = nil | |
self.extend(CategoricalData) if type == :category | |
end | |
def size | |
10 | |
end | |
end | |
a = Vector.new | |
b = Vector.new :category | |
a.size | |
#=> 10 | |
b.size | |
#=> 20 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment