Beginner: I'm confused about the display order of parameters to print
When print has a parameter list of several items, and ont of them is a method, the method value prints first in the output.
class New_class
attr_accessor :age
def my_name
print " William "
end
end
new_class = New_class.new
new_class.age = 23
print " My name is: ", new_class.my_name, " and age is: ", new_class.age
The output is
William My name is: and age is: 23
Why does "William" display out of order ? it should not be first.
Thank you. Ruby is cool !
请先登录再写评论。
Hello William,
it's displayed before "My name is" because you have print statement in my_name method
Ah. Of course.
Thank you.