I’ve been working away on the Rails course I decided to take- though as always, wishing I had more hours in the day to spend on it. It took a little longer than I would like to get through all of the setup and introduction videos, but I finally started the Ruby section last week! I’m currently learning things that, if this were my first language, I would be asking why I need to learn these things, but having been through this before I’m obsessively making notes, and looking things up! At least a couple times so far, I’ve stopped the video to look something up, only to have the instructor explain it when I resumed the video.
Some things I thought important enough to write down:
- Referencing a variable inside of a string? Use String Interpolation! Wrap ” #{ } ” around a variable or method name to insert it into the string. You must use double quotes on the surrounding string (however, if your variable points to a string, that one doesn’t need to be inside double quotes.) You can reference any class of variable- string, boolean, or number.
- Call .methods on a variable or object to see a list of methods you can call on it
- Inside of the terminal type ” irb “ to use Interactive Ruby- a tool which works like the console in your browser for JavaScript. It’s a quick and easy way to try out a bit of code without having to create or run a file.
- Stack Overflow has me believing that there’s no such thing as a function in Ruby, only methods. I want to believe. Some reading here, here, and to a lesser extent here.
- In Ruby there’s no need for a keyword to define a variable. In JavaScript we have the keywords var, let, and def, but these are not required in Ruby- you just go out there and… use your variable name!
Ruby is definitely a user-friendly language, and I feel like overall, I’m enjoying learning Ruby more compared to previous times when I’ve been learning a language. That being said, I still have a lot of ground to cover!