why this is no output? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why this is no output?

class Person attr_accessor :name , :age , :sex @name="hello" @age=15 @sex='M' end p = Person.new() puts p.name puts p.age puts p.sex #why there is no output

22nd Jul 2020, 12:09 AM
Zhengrong Yan
Zhengrong Yan - avatar
1 Answer
+ 2
You need to surround your assignments with a def initialize <code> end
22nd Jul 2020, 12:52 AM
Sandra Meyer
Sandra Meyer - avatar