News for hackers. Stuff that matters.
Re:"Useless syntax sugar": Numbered block parameters in Ruby by kubectl_h on Wednesday October 11, 2023 @09:55AM (#37844438)
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.

Re:"Useless syntax sugar": Numbered block parameters in Ruby by pawelduda on Wednesday October 11, 2023 @10:22AM (#37844772)
Yes, in repl it's convenient. I don't mind single letter block var names if the block spans one line :)
Re:"Useless syntax sugar": Numbered block parameters in Ruby by toxik on Wednesday October 11, 2023 @10:28AM (#37844843)
`ii` it is then
Re:"Useless syntax sugar": Numbered block parameters in Ruby by billyruffian on Thursday October 12, 2023 @10:26AM (#37857642)
sigh, I once encountered a PFY junior who named all variables some variation on `nx`, so `n1`, `n2`, `n99` because they 'were all just numbers'.
Re:"Useless syntax sugar": Numbered block parameters in Ruby by toxik on Friday October 13, 2023 @02:43AM (#37867504)
Using `i`, `j`, and `k` as index variables is not bad practice.
Re:"Useless syntax sugar": Numbered block parameters in Ruby by billyruffian on Friday October 13, 2023 @03:52AM (#37867965)
Well, 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.

Re:"Useless syntax sugar": Numbered block parameters in Ruby by jimmaswell on Wednesday October 11, 2023 @10:49AM (#37845148)
I would quit if I had to write multi-character index variables.