0
Why Output of this code is not David ?
class Person def initialize(name) @name = name end def get_name @name end end p = Person.new("David") puts p.get_name
6 Answers
+ 2
But output is "David". I've put this into code playground and it worked.
+ 1
yup now its working bt at that time is wasn't
0
its work
- 1
yes, it works.
- 1
p.name = "Bob" (This is the method that sets name to Bob) NB Am I right?
- 1
"David" should be the output.