Skip to content

Instantly share code, notes, and snippets.

@Y-Fujikawa
Created August 12, 2017 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Y-Fujikawa/6e627821142f5e237d7d06134fc96ecf to your computer and use it in GitHub Desktop.
Save Y-Fujikawa/6e627821142f5e237d7d06134fc96ecf to your computer and use it in GitHub Desktop.
moduleに関すること
module ViewString
def view(message)
puts message
end
end
class Sample1
# includeした場合、インスタンスメソッドとして使える
include ViewString
end
sample1 = Sample1.new
sample1.view "sample1"
class Sample2
# extendした場合、クラスメソッドとして使える
extend ViewString
end
Sample2.view "sample2"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment