Hacker News new | ask | show | jobs
by gls2ro 193 days ago
Here are four small things to remember when working with Ruby:

1. Everything is an object and the main thinking is that you send messages to objects not call methods on objects. This is very important and the core of how the language works and moreso important when reading Ruby code.

2. `false` and `nil` are falsey. Everything else is truthy when used directly in conditionals. Eg: if variable will go on true-branch when variable is anything else than `false`/`nil`. Else it will go on the else-branch.

3. Start irb (the interactive console) and use <object>.inspect + <object>.class to see what is happening. Ruby has great introspection. Remember the first thing I said here (everything is an object) so you can inspect almost anything.

4. In Ruby paranthesis are optional. Eg: user.upgrade_to "admin" is actually user.upgrade_to("admin")