[#100689] [Ruby master Feature#17303] Make webrick to bundled gems or remove from stdlib — hsbt@...
Issue #17303 has been reported by hsbt (Hiroshi SHIBATA).
11 messages
2020/11/02
[#100852] [Ruby master Feature#17326] Add Kernel#must! to the standard library — zimmerman.jake@...
SXNzdWUgIzE3MzI2IGhhcyBiZWVuIHJlcG9ydGVkIGJ5IGpleiAoSmFrZSBaaW1tZXJtYW4pLg0K
24 messages
2020/11/14
[#100930] [Ruby master Feature#17333] Enumerable#many? — masafumi.o1988@...
Issue #17333 has been reported by okuramasafumi (Masafumi OKURA).
10 messages
2020/11/18
[#101071] [Ruby master Feature#17342] Hash#fetch_set — hunter_spawn@...
Issue #17342 has been reported by MaxLap (Maxime Lapointe).
26 messages
2020/11/25
[ruby-core:101145] [Ruby master Feature#8421] add Enumerable#find_map and Enumerable#find_all_map
From:
fluff@...
Date:
2020-11-29 23:40:58 UTC
List:
ruby-core #101145
Issue #8421 has been updated by modulitos (Lucas Swart).
matz (Yukihiro Matsumoto) wrote in #note-1:
> Could you tell me a concrete use-case of your find_map and find_all_map?
> Usually a block for find/find_all gives boolean so that I personally have never wanted the return value from it.
>
> Matz.
In Ruby 2.7, I think we can use `enumerable.lazy.filter_map{..}.first` as an equivalent for `.find_map{..}`
matz (Yukihiro Matsumoto) wrote in #note-1:
> Could you tell me a concrete use-case of your find_map and find_all_map?
> Usually a block for find/find_all gives boolean so that I personally have never wanted the return value from it.
>
> Matz.
----------------------------------------
Feature #8421: add Enumerable#find_map and Enumerable#find_all_map
https://bugs.ruby-lang.org/issues/8421#change-88830
* Author: Hanmac (Hans Mackowiak)
* Status: Feedback
* Priority: Normal
----------------------------------------
currently if you have an Enumerable and you want to return the return value of #find you need eigther:
(o = enum.find(block) && block.call(o)) || nil
or
enum.inject(nil) {|ret,el| ret || block.call(el)}
neigher of them may be better than an directly maked method
same for #find_all_map
enum.lazy.map(&:block).find_all{|el| el}
it may work but it is not so good
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>