DEV Community

loading...

Discussion on: Why do you love Ruby, actually? An ode.

Collapse
sylwiavargas profile image
Sylwia Vargas Author

TESTS! I forgot about how fun and stress-free testing in Ruby is. Thank you. Maybe this is going to be next blog material.

Do you have any Ruby favorite tricks and tips? Any method(s) that deserve special appreciation?

Collapse
olivierjm profile image
Olivier JM Maniraho • Edited
  1. Accessing models and their methods in the rails console is one of my favourite
  2. Date methods are arguably the best, there is just no way Time.now.tomorrow, Time.now.yesterday, or using .first, .second(I remember I told so many people the first time I found this)
  3. There is just so many methods out of the box that are very useful

I took me a bit of time however to grasp the unless this do that or return this if that then another statement after this.
I still use rails for any new projects I create

Thread Thread
sylwiavargas profile image
Sylwia Vargas Author • Edited

DATES. That's another one that I forgot — and such an easy one to contrast with JS:
browser console showing inconsistencies of date logic in JS

It's interesting that you mention this syntax as baffling for you:

unless this do that or return this if that

For me this is the specific feature that felt like I'm playing with lego. When I later learned JS, I've developed a strong preference for refactoring if/else statements this way as well and literally everyone compliments me on this :D I wish all JS devs were trained in Ruby first so they'd write less of a spaghetti code.

Thread Thread
olivierjm profile image
Olivier JM Maniraho

It took me a while to grasp it but once I understood it I really loved it. Thanks for the article it looks interesting.