2 ms·
I really like some bits of Ruby but I kept hitting really annoying parts. e.g. salary = 100 bonus = 10 total = (bonus + salary) => 100
by emmelaich 3y ago
I really like some bits of Ruby but I kept hitting really annoying parts. e.g.
salary = 100
bonus = 10
total = (bonus
+ salary)
=> 100
Argh. The real example was more complex but you get the idea.
- jb3689 3y agoWow, I've been using Ruby for a decade and have never run into this. If you are dealing with a codebase written by someone else, then Rubocop probably has a rule for detecting these gotchas. I'd run it across the whole thing and burn down the flags.
- emmelaich 3y agoFWIW, I applied Rubocop, it said: Lint/Void: Variable bonus used in void context. Web search for 'ruby void context' finds a bunch of WTFs.