diff options
author | Nami-Doc <vendethiel@hotmail.fr> | 2013-12-02 04:25:45 -0800 |
---|---|---|
committer | Nami-Doc <vendethiel@hotmail.fr> | 2013-12-02 04:25:45 -0800 |
commit | 53272e5f112aab68458e2faab153b3c61ada8cf0 (patch) | |
tree | 4c328c34988dc2bc6eec1eae0f073e7927899463 | |
parent | 3e1e00b8f862735cd82e0deccfe4db8957b77df0 (diff) | |
parent | 02044c1eab7d7d8a670c1f63b004e91df83d22c4 (diff) |
Merge pull request #428 from davefp/ruby_attr_accessor
[ruby/en] Adds attr_accessor, attr_reader, and attr_writer to class docs
-rw-r--r-- | ruby.html.markdown | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/ruby.html.markdown b/ruby.html.markdown index bf4cb229..a4c74a4f 100644 --- a/ruby.html.markdown +++ b/ruby.html.markdown @@ -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) |