Skip to content

Instantly share code, notes, and snippets.

@rewinfrey
Created February 7, 2013 03:53
Show Gist options
  • Save rewinfrey/4728295 to your computer and use it in GitHub Desktop.
Save rewinfrey/4728295 to your computer and use it in GitHub Desktop.
self in a module is the same as self in a class (at the method level)
module IsSelf
def what_is_self?
puts "self = #{self.inspect}"
puts "self's class = #{self.class}"
end
end
class AClass
include IsSelf
def initialize
end
end
a = AClass.new
a.what_is_self?
# >> self = #<AClass:0x007fd3f190da68>
# >> self's class = AClass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment