Created
September 18, 2017 20:09
-
-
Save unixsuperhero/654c3c0733e6ae232684968a75064eea 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
#!/usr/bin/env ruby | |
module A | |
def self.included(base) | |
base.include InMethods | |
end | |
module InMethods | |
def mem | |
@mem ||= [] | |
end | |
def add(n) | |
mem += n | |
end | |
end | |
end | |
class Help | |
include A | |
end | |
h = Help.new | |
h.add(1) | |
puts(mem: h.mem) | |
__END__ | |
error-included-modules-accessing-eachother-errors.rb:14:in `add': undefined method `+' for nil:NilClass (NoMethodError) | |
from error-included-modules-accessing-eachother-errors.rb:24:in `<main>' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment