Skip to content

Instantly share code, notes, and snippets.

@maxjustus
Created January 25, 2012 16:23
Show Gist options
  • Save maxjustus/1677060 to your computer and use it in GitHub Desktop.
Save maxjustus/1677060 to your computer and use it in GitHub Desktop.
Ruby Decor8rz
class A
def hi
'hi'
end
end
module B
def hi
super + 'hi'
end
end
a = A.new
a.hi
>> 'hi'
a.extend(B)
a.hi
>> 'hihi'
#or more succinctly
a = A.new.tap |a|
a.extend(B)
end
a.hi
>> 'hihi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment