Skip to content

Instantly share code, notes, and snippets.

@gaffneyc
Created January 23, 2013 16:52
Show Gist options
  • Save gaffneyc/4609767 to your computer and use it in GitHub Desktop.
Save gaffneyc/4609767 to your computer and use it in GitHub Desktop.
Classes over methods?
# 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