In Ruby, is require('my_thing') equivalent to require 'my_thing'? It's just the ruby convention that you don't need to wrap a function's arguments in paranetheses right?
You are right, you don't need them, however, I think you need to know one important thing before deciding to ditch them all-together in your method calls (regarding your question on conventions):
According to the Ruby Style Guide:
Omit parentheses around parameters for methods that are part of an internal DSL (e.g. Rake, Rails, RSpec), methods that have "keyword" status in Ruby (e.g. attr_reader, puts) and attribute access methods. Use parentheses around the arguments of all other method invocations.
Since require has a "keyword" status in Ruby, it's okay to not use parentheses. If, however, you made your own my_require method, then it would be a better idea to use them.
Allowing omission of parentheses around the argument is a language feature, not a convention.
It is a convention to omit parentheses for methods defined on the Kernel module that start with lower case. require is one of them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With