You’ve now gotten an introduction to all of the Ruby grammar that you’ll need to build industrial-grade applications. In particular, our next step will be to define classes and inherit from amazingly powerful parent classes that brilliant, generous Ruby developers have shared with the community. This is going to let us build very quickly, without reinventing the wheel. We call this collection of parent classes that we’ll be inherting from “Ruby on Rails”.
However, the more Ruby fluency we have before we get to Rails, the better. So, here are a bunch of puzzles/exercises for you to stretch your legs with. Some things to keep in mind as you are working on them:
Try to have a plan (at least for what your first step is) before you start typing.
The hard part about programming is not writing the code; it’s learning how to think very precisely about solving problems, and breaking your solution down into steps that are so simple that you can tell the computer how to do them.
p
to see what’s going on, don’t guess.undefined method
? Why? Did you make a typo in the method name? More likely, the object you have is of a class that you are not expecting. Follow it back to where it came from and figure out why.Try to use the information contained in the previous Chapters to MacGuyver a solution to the problem. Try not to Google for a solution; the things you find on Stack Overflow will likely confuse you more than help you.
There is at least one solution to every puzzle using only methods we’ve covered together.
Here are the challenges1. Good luck! Ask lots of questions on Piazza!
The source of these challenges is the very excellent exercism.io, a community resource for programming practice and mentorship. ↩