I think it is worthwhile to distinguish what syntax is enforced, and which is a convention. Ruby on Rails is very opinionated about camel casing because it also expects to find files with the equivalent snake name. But ruby itself doesn't enforce this. So for example Constants only need the first letter to be uppercase (capitalised), but by convention we upcase entire the entire variable.
These are two ways to assign a constant. Constants can also be re-assigned just like variables, but in certain cases it produces a warning. Class names are constants themselves, which are typically capitalised like in the first example.
The whole idea of this article is to point out the best practices of using the cases. Even though naming the constant like this,
Name = "Fred"
is allowed, but it will throw ' lint issue ' which is surely not a good practice.
If you would like, you can have an idea of possible good and bad practices here: github.com/rubocop-hq/ruby-style-g...
So whatever is mentioned here is said by considering the lint standards, which I am planning to cover in the next article.
I really appreciate your effort in pointing out this. Keep reading 🙂
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I think it is worthwhile to distinguish what syntax is enforced, and which is a convention. Ruby on Rails is very opinionated about
camel
casing because it also expects to find files with the equivalentsnake
name. But ruby itself doesn't enforce this. So for example Constants only need the first letter to be uppercase (capitalised), but by convention we upcase entire the entire variable.These are two ways to assign a constant. Constants can also be re-assigned just like variables, but in certain cases it produces a warning. Class names are constants themselves, which are typically capitalised like in the first example.
Hi shushugah,
The whole idea of this article is to point out the best practices of using the cases. Even though naming the constant like this,
is allowed, but it will throw ' lint issue ' which is surely not a good practice.
If you would like, you can have an idea of possible good and bad practices here: github.com/rubocop-hq/ruby-style-g...
So whatever is mentioned here is said by considering the lint standards, which I am planning to cover in the next article.
I really appreciate your effort in pointing out this. Keep reading 🙂