Skip to content

Instantly share code, notes, and snippets.

@austinthecoder
Created August 6, 2010 19:33
Show Gist options
  • Save austinthecoder/511866 to your computer and use it in GitHub Desktop.
Save austinthecoder/511866 to your computer and use it in GitHub Desktop.
# A class that looks like this..
class A
def initialize(x, y)
@x = x
@y = y
end
attr_accessor :x, :y
end
# ..can be created like this..
A = Struct.new(:x, :y)
# ..if you need additional methods:
class A < Struct.new(:x, :y)
def my_method
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment