Created
August 6, 2010 19:33
-
-
Save austinthecoder/511866 to your computer and use it in GitHub Desktop.
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
# 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