Skip to content

Instantly share code, notes, and snippets.

@maxdignan
Created March 4, 2018 18:01
Show Gist options
  • Save maxdignan/93a7c4d15f4152a29c9e774cce0634a4 to your computer and use it in GitHub Desktop.
Save maxdignan/93a7c4d15f4152a29c9e774cce0634a4 to your computer and use it in GitHub Desktop.
module Talkable
def speak(word)
puts word
end
end
class MyClass
def some_method
...
end
end
#MyClass can be given the ability to talk by including the Talkable module in it like so
class MyClass
include Talkable
end
MyClass.new.speak('hi') #puts 'hi'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment