3 ms·
> I can't fathom optional parenthesis. I think this kind of falls in line with the idea of Ruby giving you sharp knives[0]. Like you I used to have a love / h
by nickjj 4y ago
> I can't fathom optional parenthesis.
I think this kind of falls in line with the idea of Ruby giving you sharp knives[0].
Like you I used to have a love / hate relationship with this because it feels inconsistent to sometimes use parenthesis and sometimes not. In a world where you just want to run Python's Black code formatter and always use parenthesis, having to think about when to use parenthesis feels really tedious.
But I think nowadays I'm happy that they are optional because when you want them to be optional it creates a really nice aesthetic to your code.
For example with Rails you can do: `2.days.ago` and then there's also things that feel like a mini DSL such as `validates :title, :body` or `belongs_to :users`. These just look nicer without parenthesis.
With that said, I do use parenthesis more often than not but it's nice to avoid using them when it makes something look nicer visually.
[0]: https://rubyonrails.org/doctrine#provide-sharp-knives https://rubyonrails.org/doctrine#provide-sharp-knives