0

Did Ruby accessor stop working or am I doing something wrong?

Yesterday I was learning about accessory for Ruby and seemed to get it work in one of my codes but now when I try again there is no output. I might remember wrong but yesterday attr_accessor had blue font for the accessed. I would appreciate an answer. class Something attr_accessor :number def initialize(number) @num=number end end number1=Something.new(10) puts number1.number

13th Mar 2018, 4:45 PM
Remains
Remains - avatar
3 Answers
+ 3
You have made a small error. The code works like this: class Something attr_accessor :num def initialize(number) @num=number end end number1=Something.new(10) puts number1.num
13th Mar 2018, 5:28 PM
Paul
Paul - avatar
+ 3
You are welcome. I like questions like these.
13th Mar 2018, 5:34 PM
Paul
Paul - avatar
0
Thank for your answer. That fixed it. Much appreciated.
13th Mar 2018, 5:33 PM
Remains
Remains - avatar