The last few days I’ve been plowing through the Codecademy Ruby track, and I finally finished. There was a lot of information in there. The later parts of the course that I did today and which were more Ruby-specific (as opposed to syntactical differences to concepts I had previously been exposed to) got a bit dense. Tomorrow I’m going to go through the Ruby quizzes at Treehouse and watch the videos on anything that I have trouble with. I think waiting until tomorrow to do that will help. Everything’s still fresh in my mind now, but if I wait a day the sharpness of some of the information may fade a little. Perfect time to reinforce skills!
Some of the things I learned today:
- Refactoring and general best practices for writing Ruby more concisely.
- Ruby has an implicit return.
- Shoveling to add items to an array.
- Blocks vs. Procs vs. Lambdas (explained more below)
- Classes! (also elaborated on below)
- Modules! These are similar to classes, but they’re pretty static. They’re basically used so that we can store values and methods.
- Public vs. private methods.
Blocks, procs, and lambdas are all very similar with subtle differences. Blocks are technically not objects. They’re just blocks of code, and can’t be named or re-used. Procs are like blocks that you define and give a name. They are true objects, and can be called multiple times. They do not check for arity (the number of arguments something takes) – if you give too few arguments it will use “nil” for the missing ones, and if you give too many it will ignore the extras. Procs also do not pass control back to the calling method when they return. Lambdas are like procs, except they do check for arity, and they do pass control back to the calling method after they return.
Creating a Class is basically the way to define a type of something. You can create multiple instances of any given class. Classes can also inherit methods from parent classes, and we can use mixins to allow classes to use methods from modules – a way of getting around the restriction Ruby classes have of only being able to have one superclass (or parent).
Today has been a lot of information absorption. I’m looking forward to revisiting the concepts I learned today to make sure I have a good grasp of them.