This community-built FAQ covers the “Variables & Data Types” exercise from the lesson “Introduction to Ruby”.
Paths and Courses
This exercise can be found in the following Codecademy content:
Learn Ruby
FAQs on the exercise Variables & Data Types
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 (
) 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 (
) below!
Agree with a comment or answer? 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!
in the exercise - " Create a second variable called my_age
and set it equal to your age as a number (don’t use any quotes around the number)."
can someone explain why i should not use quotes around numbers? is there a reason?
Because we’re setting my_age as a numeric data type, and not a string. Only strings get quotation marks because they’re meant to represent words and phrases. Of course in some instances a phrase can contain a number, but then that number would be part of a string and not a numeric data type itself.
Think of it like this: You could type “It puts the lotion on its skin or it gets the hose again” without quotation marks and it would be a problem because puts means something in Ruby. So the quotation marks let Ruby know that it’s a string, and it won’t act on puts (just as an example) the way it would if there were no quotation marks.
Ruby knows that a number is a number, though. So you don’t need quotation marks around purely numeric data types.
1 Like
Also, you COULD use quotes around a number if you solely just wanted to print that number out. But if you wanted to use it to solve some kind of math problem later, that’s not going to work. For example:
a = “10”
b = “15”
c = a+b
puts c
will come out as 1015. But remove the quotes around the numbers and it will come out as 25.
1 Like