I'm a beginner in Ruby, but I stumbled after studying a class.
I was studying by looking at the text passed, but I couldn't understand it because there was a method without any explanation.
(The text is confidential and cannot be posted.)
"Attr_accessor" ← I'm not sure about this method.

Also, what do you keep in mind when creating notes and memos?
I'm wondering how to put it together in an easy-to-understand manner.
In the end, it feels like I'm always copying the text, and I'm worried if this is okay.


・ Referenced articles

・ What I understood
What I understood was "attr: attribute meaning: abbreviation for attribute"

-When I want to define the attributes of an object that can be read and written
By the way, attr_reader is used when I want to define read-only attributes.
Attr_writer is used when I want to define write-only attributes.
Is written in the article.
After all, it's just input and it's refreshing what it's used for.

I'm sorry, but thank you.

  • Answer # 1

    Articles written by individuals are also good,officialLet's also cherish the source of information. Fortunately, Ruby is developed by Japanese people, so there are plenty of Japanese documents.

    instance method Module # attr_accessor --Rurima

    It is a method that defines the method as listed here (Ruby is a language that can control the code of the method definition itself).