(This is the final lesson in Ruby…?)
It’s past midnight now, but starting today (Thursday), we will start learning Git and GitHub. The problem is, I already learned Git and GitHub last year when I took their WordPress Development blueprint program. I guess this means, more time doing some supplemental learning of the basics of Ruby, right? Yup. Right on.
In Day 12, we learned the two final basics of Ruby: attribute accessors and symbols. I didn’t post this code on my previous post, but this particular one was my assignment when we learned object orientation, ancestry and inheritance, and class methods and class variables.
Below was my object orientation sample code that I did back at Day 11. Yes, I’m using the manga topic as an example.
With atrribute accessors, I’m using the attr_accessor
method to shorten all of that code into something much simpler and cleaner. Here is how we use that method to refactor the code shown above:
The attribute accessor is the “set” and “get” (from the original code above) combined as one. This is a very useful method, especially when there’s going to be a lot of user input to be collected, like my entire collection of manga, for example.
Last, but not least, we learned about symbols. You see the classes :title, :mangaka, :genre
having colons in front of them. That’s what they are. The colons are called symbols. Unlike variables, symbols don’t really mean anything. Just using symbols in front of classes reminds Ruby on what to do with them. If we call them out using the puts
command, nothing will happen. Along with symbols, we also learned about hashes. Hashes are kind of like arrays, but they store a list of info regarding one object. With symbols combined, collecting data from user input is a lot easier and cleaner to refactor.
Again, the whole manga theme:
The test result of this script is the terminal screenshot shown at the top of this entry.
And that would be it for the basics of Ruby (or probably basics in general programming). Now I need to do more supplement studying.
Now that I thought of it, maybe I should start opening a tutorial series about Git and GitHub as I go along my Git/GitHub class? What do you all think?
July 28, 2016 @ 10:04 am
Nice example! 😀
July 29, 2016 @ 11:41 pm
One thing I love about Skillcrush is that the instructors give us the freedom to create our own files, as long as we have the basic understanding of what we do. Of course I would use a manga theme (or anything related) for my assignments LOL. <3
July 30, 2016 @ 8:23 pm
I like it when courses allow a certain level of customization like that, it makes it easier to get motivated because you’re making something cool 😀
July 30, 2016 @ 8:34 pm
Their example code involves cats and dogs and owners, so why not manga? LOL. That’s how laid back the instructors are. 😀
July 30, 2016 @ 9:23 pm
That’s awesome!