Contents
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.
·keyword
"Attr_accessor"
・ Referenced articles
https://qiita.com/Hassan/items/0e034a1d42b2335936e6
・ What I understood
What I understood was "attr: attribute meaning: abbreviation for attribute"
is
-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
Related articles
- ruby - i want to know the reason for implementing it in a class method or module when solving an exercise
- ruby on rails - [rails] i want to use each statement in a helper method
- ruby - returns the method further as a method
- ruby - the method defined in the model cannot be used
- ruby - binary data conversion method
- java - i don't understand the method call inside the class type method
- ruby - no method error rails
- ruby - i'm using the errors method, but i don't get an error message
- javascript - i want to understand the filter method with the function function
- ruby on rails: undefined method ʻuser'for nil: about nomethoderror of nilclass
- ruby - undefined method `save'for nil: nilclass cannot be resolved
- ruby - improvement of nomethoderror undefined method `paginate'
- ruby on rails - [rails] i want to make it a helper method
- ruby - nomethoderror: undefined method `new'for: uglifier: symbol error on heroku deployment
- [ruby] i don't understand the meaning of the error statement
- ruby on rails 5 - undefined method `tomorrow'for 00: i would like to know how to solve bigdecimal
- the ruby on rails each method does not repeat well
- ruby on rails - i want to use yield in a method chain
- ruby - where method doesn't work
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
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).