Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Basics (Retired) Ruby Methods Method Returns: Part 2

Jorge Valle
Jorge Valle
2,448 Points

How can you do string interpolation with arguments from a method?

I know this is pretty simple and I know I almost got it, but I keep getting an error and I don't know exactly what it is. Any help would be appreciated.

method.rb
def mod(a, b)
  #write your code here
end

2 Answers

Ilya Dolgirev
Ilya Dolgirev
35,375 Points

Just use #{} in your sentence to place all your values.

a = 2
b = 5
puts "Result of multiplying #{a} and #{b} is #{a * b}"
Jorge Valle
Jorge Valle
2,448 Points

I knew I almost had it! I was trying to create another argument with the "c" variable.

Thanks for the help!