Created
January 23, 2013 16:52
-
-
Save gaffneyc/4609767 to your computer and use it in GitHub Desktop.
Classes over methods?
This file contains hidden or 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
# SomeClass.new("arg1", "arg2").call | |
class SomeClass < Struct.new(:arg1, :arg2) | |
def call | |
@arg1 + @arg2 | |
end | |
end | |
# vs | |
# SomeClass.new.some_method(arg1, arg2) | |
# instance.some_method("arg1", "arg2") | |
class SomeClass | |
def some_method(arg1, arg2) | |
arg1 + arg2 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment