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 Arguments

Rwanda Muhammad
seal-mask
.a{fill-rule:evenodd;}techdegree
Rwanda Muhammad
Full Stack JavaScript Techdegree Student 4,116 Points

The Method Arguments are not working, I keep getting the answer 4. Is there a work around for this assignment?

def add(a, b)

puts "Adding # {a} and # {b} puts a + b end

add(2, 3) add(5, 5) add(6, 6)

1 Answer

Ilya Dolgirev
Ilya Dolgirev
35,375 Points

Hi! At first glance you have some syntax mistakes there:

  • Extra spaces in "#{}"
  • String must end with closing quote
  • Method calls should start with new line

Please, use Markdown Cheatsheet below to properly format your questions in the future :)

I believe it should look something like:

def add(a, b)
  puts "Adding #{a} and #{b}"
  puts a + b
end

add(2, 3)
add(5, 5)
add(6, 6)