News for hackers. Stuff that matters.
Re:Read this post ‘unless’ you’re not a Ruby developer by soheil on Tuesday December 13, 2022 @05:36AM (#33966974)
If you're returning who cares about the scope? Are you saying visually you'd like to have indentation inside the if body? If that's the case there is also nothing stopping you in most languages from doing something as nasty as:

  a=1;b=2;c=3;d=a+b==c?4:5;return d
Re:Read this post ‘unless’ you’re not a Ruby developer by moonchrome on Tuesday December 13, 2022 @05:56AM (#33967134)
I do because return means end of scope. Except in your example it hides the fact that it's creating it's own scope.

I'm not arguing other languages can't produce bad code, just that ruby is particularly suited for it especially as number of developers working on code increases. I've seen people propose a linter to enforce consistency - but at that point I might as well chose a language with better design choices - plenty of alternatives these days.

Re:Read this post ‘unless’ you’re not a Ruby developer by multiplegeorges on Tuesday December 13, 2022 @08:36AM (#33968617)
> I've seen people propose a linter to enforce consistency - but at that point I might as well chose a language with better design choices - plenty of alternatives these days.

You're seriously proposing that adding a linter has the same organizational costs as changing languages entirely. Meanwhile, back in the real world...

Ruby has major advantages over many other languages and a linter is basic tooling you should have in every development environment.

Re:Read this post ‘unless’ you’re not a Ruby developer by codesnik on Tuesday December 13, 2022 @08:26AM (#33968495)
It doesn't create no scope. Even for variables.
Re:Read this post ‘unless’ you’re not a Ruby developer by ezekg on Tuesday December 13, 2022 @03:57PM (#33975664)
Ruby doesn't create a new scope for if/unless.