mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
Ruby: Adds attr_accessor, attr_reader, and attr_writer to class docs
This commit is contained in:
parent
a36cee194b
commit
02044c1eab
@ -323,6 +323,13 @@ class Human
|
||||
@name
|
||||
end
|
||||
|
||||
# The above functionality can be encapsulated using the attr_accessor method as follows
|
||||
attr_accessor :name
|
||||
|
||||
# Getter/setter methods can also be created individually like this
|
||||
attr_reader :name
|
||||
attr_writer :name
|
||||
|
||||
# A class method uses self to distinguish from instance methods.
|
||||
# It can only be called on the class, not an instance.
|
||||
def self.say(msg)
|
||||
|
Loading…
Reference in New Issue
Block a user