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

2nd Dec 2016, 1:15 PM
abhishek sharma
abhishek sharma - avatar
6 ответов
+ 2
But output is "David". I've put this into code playground and it worked.
3rd Dec 2016, 10:13 AM
Maciej Dobosz
Maciej Dobosz - avatar
+ 1
yup now its working bt at that time is wasn't
3rd Dec 2016, 4:03 PM
abhishek sharma
abhishek sharma - avatar
0
its work
12th Jan 2017, 5:33 PM
Amit Sharma
Amit Sharma - avatar
- 1
yes, it works.
29th Dec 2016, 3:53 AM
Cristian Baeza Jimenez
Cristian Baeza Jimenez - avatar
- 1
p.name = "Bob" (This is the method that sets name to Bob) NB Am I right?
7th Jan 2017, 11:15 PM
John Maleckar
- 1
"David" should be the output.
18th Feb 2017, 3:10 AM
vancouver fun
vancouver fun - avatar