Skip to content

Instantly share code, notes, and snippets.

@vinniefranco
Created December 31, 2010 00:43
Show Gist options
  • Save vinniefranco/760557 to your computer and use it in GitHub Desktop.
Save vinniefranco/760557 to your computer and use it in GitHub Desktop.
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