jeudi 29 juin 2017

How after manipulations with two strings get a string in result as well

Write a method, #present_pet, that takes two arguments: a pet name and an animal type, both strings. It should return a string that announces the pet (e.g. if given "Todd" and "turtle", it should return "Todd the turtle has arrived.").

def present_pet(pet_name, animal)
  pet_name.each_line do |pet_name|
    animal.each_line do |animal|
      puts pet_name[pet_name] + " " + "the" + " " \
           + animal[animal] + " " + "has arrived."
    end
  end
end

and after I run it, I get just the sentence not converted to a string! how would I make it a string ?

Aucun commentaire:

Enregistrer un commentaire