Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment