Skip to content

Instantly share code, notes, and snippets.

@krainboltgreene
Created January 17, 2012 03:14
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save krainboltgreene/1624327 to your computer and use it in GitHub Desktop.
module ExampleModule
def amethod
end
end
class AClass
end
apre_imethods = AClass.instance_methods
apre_smethods = AClass.singleton_methods
class AClass
include ExampleModule
extend ExampleModule
end
p AClass.instance_methods - apre_imethods
p AClass.singleton_methods - apre_smethods
class BClass
end
bpre_imethods = BClass.instance_methods
bpre_smethods = BClass.singleton_methods
class BClass
extend ExampleModule
include ExampleModule
end
p BClass.instance_methods - bpre_imethods
p BClass.singleton_methods - bpre_smethods
opre_imethods = Object.instance_methods
opre_smethods = Object.singleton_methods
class Object
include ExampleModule
extend ExampleModule
end
p Object.instance_methods - opre_imethods
p Object.singleton_methods - opre_smethods
module ExampleModule
def amethod
end
end
class AClass
end
apre_imethods = AClass.instance_methods
apre_smethods = AClass.singleton_methods
class AClass
include ExampleModule
extend ExampleModule
end
p AClass.instance_methods - apre_imethods
p AClass.singleton_methods - apre_smethods
class BClass
end
bpre_imethods = BClass.instance_methods
bpre_smethods = BClass.singleton_methods
class BClass
extend ExampleModule
include ExampleModule
end
p BClass.instance_methods - bpre_imethods
p BClass.singleton_methods - bpre_smethods
opre_imethods = Object.instance_methods
opre_smethods = Object.singleton_methods
class Object
extend ExampleModule
include ExampleModule
end
p Object.instance_methods - opre_imethods
p Object.singleton_methods - opre_smethods
@krainboltgreene
Copy link
Author

~/Repositories ‹ruby-1.9.3› $ ruby exin.rb
[:amethod]
[:amethod]
[:amethod]
[:amethod]
[:amethod]
[:amethod]
~/Repositories ‹ruby-1.9.3› $ ruby inex.rb
[:amethod]
[:amethod]
[:amethod]
[:amethod]
[:amethod]
[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment