Created
August 12, 2017 08:44
-
-
Save Y-Fujikawa/6e627821142f5e237d7d06134fc96ecf to your computer and use it in GitHub Desktop.
moduleに関すること
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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