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 !
2 comments
Comment actions Permalink

Hello William,

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

0
Comment actions Permalink

Ah. Of course.
Thank you.

0

Please sign in to leave a comment.