Created
December 31, 2010 00:43
-
-
Save vinniefranco/760557 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
class Example | |
def initialize(name) | |
# this means there is an instance var of name in this object. | |
@name = name | |
end | |
# This is the ruby equivilant to this JS class method | |
# | |
# function name() { | |
# return this.name; | |
# } | |
# | |
def name | |
@name | |
end | |
# This is the ruby equivilant to this JS class method | |
# | |
# function setName(name) { | |
# this.name = name; | |
# } | |
# | |
def name=(name) | |
@name = name | |
end | |
end | |
# and here is a symbol shortcut in ruby | |
class Example | |
attr :name | |
def initialize(name) | |
# this means there is an instance var of name in this object. | |
@name = name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment