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

Answer and Given sentence out of sync.

For the Last Ruby Basic code challenge a sentence is given for the answer that contains ""s which screw up the interpreter, and require " being replaced with \"

Which is done, and the "vars" are replaced with vars, but it complains of spelling and punctuation. And sentence given looks like it has everything so what is wrong?

method.rb
def mod(a, b)
  #write your code here
  return "\"The remainder of a divided by b is c.\" where #{a} is your \"a\" variable, #{b} is your \"b\" variable, and c is the value of #{a % b}."
end

2 Answers

Vlad Filiucov
Vlad Filiucov
10,665 Points

First of all you don't need return key-word because last evaluation is returned by default in ruby. You don't need to escape () What task is saying that you should replace a b and c in that string with embeded ruby-code. so you should have "The remainder of #{a} divided by #{b} is #{a % b}."

Then they should fix the wording of that given sentence that people/customers use from ""The remainder of a divided by b is c." where a is your "a" variable, c is your "b" variable, and c is the value of a % b." to "The remainder of a divided by b is a % b". So there is much less trouble in trying to find out what is wrong when doing the challenge since the given sentence was not anywhere near the same sentence in the answer.

Vlad Filiucov
Vlad Filiucov
10,665 Points

In software development career you will often encounter situations when the task isn't clear or isn't set correctly. You will have to ask for a lot of details. Trust me. To be fair, it was clear to me that they wanted to point out a, b and c by taking them into parentheses. So if you got it working just go on.