What do you think about being able to use don't in addition to do in blocks?
For example:
numbers = 1..5
numbers.select do |num|
num.even?
end # => [2, 4]
numbers.select don't |num|
num.even?
end # => [1, 3, 5]
In that way we could deprecate, and eventually remove, Enumerable#reject. We don’t want aliases in the language, so that would move us closer to that goal.
Of course this could be applied to any method that receives a block.
It could even be composed with another proposal I had in mind:
A do!, and potentially don't! could emit code that can be executed in parallel. No need to wait for one iteration to launch the next one. This is not the same as spawning in each iteration. This could adapt however is needed to run the body in parallel, not just concurrently, and maybe with SIMD instructions one day.
I don’t have any good reason for this, but I would strongly prefer dont over don't. To have the apostrophe in don't would bother me more than what it would it be worth to me to keep it proper English. I see the apostrophe as an operator outside of a string (you also wouldn’t use one as part of a variable’s name).
That’s just my opinion, but maybe others feel similar.
EDIT: Would there be also a one-liner version of it? I mean like select{|foo| foo.bar}
The original post was written on April 1. At least it was that day in Argentina where the author lives. If you’re further east, Discourse might show a different date based on your UTC offset.
Hm, that’s odd though. Observed time in (metropolitan) France should be 2022-04-01 23:36 CEST (UTC+2). At least that’s what I’m shown in that same time zone.
Yeah, my previous comment shows as being posted 1 minute ago at 11:13, but it’s actually 12:13 now.
I observe the same wrong offset in another browser. But I get the correct time on a different machine. So it seems to be my local setup. Perhaps it’s related to the fact that I haven’t restarted the system and browser since the daylight savings switch two weeks ago
EDIT: Yep, my browser thinks it’s still CET (UTC+1) instead of CEST (UTC+2)