Mastery Quizzes Chapter 2 Question 1
Closed this issue · 4 comments
The question asks to write a program that uses constants to define the numbers 1 to 10 as numerals.
I have attempted the following which puts out 1 but the program still seems to fail:
I've been searching google for ages to see what 'uninitialized constant' means but can't see where I am going wrong - can someone tell me if I'm heading in the right direction or have I got this completely wrong?!
Thanks :)
Hey Darcie. I think the reason is that RSpec is having a hard time finding your constants. You are on the right track though. Like your comment said, in order to get 1 returned, you need to input Numbers::ONE. However, the test isn't designed to use Numbers::ONE. It's only looking for ONE.
Does that make sense?
Hey Alex, thanks for your reply.
Hmm kind of but struggling to work out how to define the numbers - do I not need the 'class Numbers' bit then?
Yeah, you're right. You can define them without putting them in a class! :)
This link really helped me understand constants in ruby:
http://www.rubyguides.com/2017/07/ruby-constants/
BAH such a simple solution! I just thought surely it can't be that easy haha.
Thanks for your help :)