News for hackers. Stuff that matters.
Re:Read this post ‘unless’ you’re not a Ruby developer by mjevans on Tuesday December 13, 2022 @02:20PM (#33974290)
Perl also had that delayed syntax check style as an option and I HATED IT.

THING if logical condition

Filter First is far better self-documentation: if condition THING

Re:Read this post ‘unless’ you’re not a Ruby developer by layer8 on Tuesday December 13, 2022 @04:12PM (#33975859)
It works well in cases where you have an operation that consists of a certain sequence of statements, where one of the statements has to be omitted in a particular atypical situation. Instead of having interrupt the sequence with an if, you just tag the particular statement with the omitting condition at the end. That’s also when unless tends to be intuitive, because it suggests an atypical condition.
Re:Read this post ‘unless’ you’re not a Ruby developer by hosh on Tuesday December 13, 2022 @06:49PM (#33978002)
That is usually where I used it too.

When I started writing these as pipeline execution. Then I’ll use a maybe?() instead if the conditional does not need to depend on the result of a previous operation.

Re:Read this post ‘unless’ you’re not a Ruby developer by hosh on Tuesday December 13, 2022 @02:25PM (#33974347)
That's a matter of what fits better with the structure of how you think internally, and not necessarily that there is an objectively better way for self-documentation.

For example, I can totally see how imperative-first would mess up people with neurodivergant brains.

Tangent -- Ruby takes a lot of inspiration from Perl.