FAQ: The Zen of Ruby - String Interpolation

This community-built FAQ covers the “String Interpolation” exercise from the lesson “The Zen of Ruby”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn Ruby

FAQs on the exercise String Interpolation

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

On the string interpolation activity you can reference the array favourite_things by just using #{thing} for each one

There is no code showing how it is assigned? can someone help me out

the lesson should start with this code:

favorite_things = ["Ruby", "espresso", "candy"]

puts "A few of my favorite things:"

favorite_things.each do |thing|
  puts "I love " << thing << "!"
end

so its show how thing is assigned? .each has hopefully been taught, if not, surely it will come later.

It starts with the block parameter, |thing|, which acts as the iteration variable in the each loop. As the array is iterated, each element will in turn be assigned to thing which is interpolated in #{thing} within the output string expression.

2 Likes

If you are getting the right output but it’s not letting you move onto the next exercise check that you have not left a space before the ! because thats what was stopping me from being able to proceed.

5 Likes

dont seem to be winning

What is the expected output? And does that match with the output you see?

the expected output was identicle when asked for the solution

The expected output:

A few of my favorite things:
I love Ruby!
I love espresso!
I love candy!

your output:

A few of my favorite things:
["Ruby", "espresso", "candy"]
["Ruby", "espresso", "candy"]
["Ruby", "espresso", "candy"]

how are those the same/identical?

1 Like

Ah! the syntax error kept saying it doesn’t say ‘I love Ruby’ then when i asked for the solution, it gave me the same output from my incorrect code that’s why i was confused.

Could you show me what the code looks like please? and thank you for such a prompt response, as I am a beginner to this language, soaking up as much as I can.

you where pretty close. you have the string ("I love #{things}!"), but you forget to print (puts`) the string.

aaaah man!! Thank you so much

It fails to say that you need an exclamation point. Who made this? So many errors.