4 ms·
We outlawed it immediately via Rubocop but I use it all the time in IRB. We also don't allow single letter variable names. I'm an old school rubyist and find t
by kubectl_h 3y ago
We outlawed it immediately via Rubocop but I use it all the time in IRB.
We also don't allow single letter variable names. I'm an old school rubyist and find this to be an annoying constraint that can't be auto-corrected so it adds a little friction to writing code but arguing for more terse code is always a losing proposition so I just deal with it.
- pawelduda 3y agoYes, in repl it's convenient. I don't mind single letter block var names if the block spans one line :)
- toxik 3y ago`ii` it is then
- billyruffian 3y agosigh, I once encountered a PFY junior who named all variables some variation on `nx`, so `n1`, `n2`, `n99` because they 'were all just numbers'.
- toxik 3y agoUsing `i`, `j`, and `k` as index variables is not bad practice.
- billyruffian 3y agoWell, my attempt at a humorous aside didn't land. To be strictly serious we are talking about block parameters in ruby which contain the values yielded to it which, in an enumeration, is likely to be a value object from a collection and only occasionally an index (where you've explicitly chained `#with_index` for e.g.). If you are nesting deep enough in ruby to call for `k` then, yes, it would be bad practice.
- jimmaswell 3y agoI would quit if I had to write multi-character index variables.