[#115884] Windows Ruby 3.2.2: Non-English character added to Windows Registry String Value — Jay Mav via ruby-core <ruby-core@...>
Hello,
3 messages
2023/12/24
[ruby-core:115815] [Ruby master Feature#20049] Destructive drop_while for Array and Hash
From:
"zverok (Victor Shepelev) via ruby-core" <ruby-core@...>
Date:
2023-12-20 09:03:30 UTC
List:
ruby-core #115815
Issue #20049 has been updated by zverok (Victor Shepelev).
> Could you explain the use-case for the new method, please?
Not the original author, but I think one of the frequent use cases is some parser- or scanner-alike code. E.g., after reading some "dirty" data,
```ruby
lines.drop_while! { ln.match?(/HEADER:/) }
# operate with clean `lines` here
```
(I had more generic take on this in my ticket about "consuming" enumerators #19061, which I haven't had time to pursue the better proposal/explanation this year, but want to return during the next one.)
----------------------------------------
Feature #20049: Destructive drop_while for Array and Hash
https://bugs.ruby-lang.org/issues/20049#change-105764
* Author: chucke (Tiago Cardoso)
* Status: Feedback
* Priority: Normal
----------------------------------------
I propose a "drop_while!" variant for arrays and hashes, which changes the current instance.
```ruby
h = {foo: 0, bar: 1, baz: 2}
h.drop_while!{|element| key, value = *element; value < 2 }
h #=> # => { baz: 2 }
```
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/