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

Unable to get this right

This code just seams right but I can4t make it working , please help

method.rb
def mod(a, b)
  c = a%b
  return β€œThe remainder of #{a} divided by #{b} is #{c}.”
end

puts mod(2, 3)

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're doing just fine! My guess is that you may have done some of this code in a text editor that is "smart" and changing your quotation marks for you. Take a close look at the quotation marks in your code. They are the slanted version.

Your code:

return β€œThe remainder of #{a} divided by #{b} is #{c}.”

Correct code:

return "The remainder of #{a} divided by #{b} is #{c}."

Also, your final puts statement is not needed as the challenge will call the function for you and pass in the values they choose.

Hope this helps! :sparkles:

Hiya,

You're right. I've found if you copy the string from the question (I know, I'm lazy!) it gives you the stylised ones. I've head-scratched on that many times! There's a couple of the Swift and Java courses where this crops up from time-to-time too.

Steve.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Steve Hunter It's because the quotation marks in the instructions are the stylized ones in some cases. This is one of them. However, there are occasions where people have had this happen from text they copied from their local machines. I know that Microsoft Word is especially guilty of doing this :smiley:

Word is a nightmare for most things, I find! :smile:

TY Jennifer! :) stupid to have different double quotes though. Like many lazy programmers out there copy paste is a regular habit :)