The reason why I prefer to keep declaration and conditionals separated is because it helps a bit with reading the code and I've found more than once that it is not always understood!
I've seen teammates trying to "fix" it as if user == User.find(params[:id]) because they weren't understanding I was just assigning something! Besides, Ruby emits a warning in this case... so it is not clear at all even when you can do it.
The difference with the case of the constants is that the constants declaration doesn't usually involve your applications's logic, so it is easier to reason about and less "dangerous".
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.
xD not at all.
The reason why I prefer to keep declaration and conditionals separated is because it helps a bit with reading the code and I've found more than once that it is not always understood!
I've seen teammates trying to "fix" it as
if user == User.find(params[:id])
because they weren't understanding I was just assigning something! Besides, Ruby emits a warning in this case... so it is not clear at all even when you can do it.The difference with the case of the constants is that the constants declaration doesn't usually involve your applications's logic, so it is easier to reason about and less "dangerous".