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 "

  new_class =
  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 !
Comment actions Permalink

Hello William,

it's displayed before "My name is" because you have print statement in my_name method

Comment actions Permalink

Ah. Of course.
Thank you.


Please sign in to leave a comment.