[ruby-core:121065] [Ruby master Feature#16993] Sets: from hash keys using Hash#key_set

15 Feb
2025
15 Feb
'25
4:07 a.m.
Issue #16993 has been updated by nobu (Nobuyoshi Nakada). This kind of extensions should be done in the corresponding library side, set.rb. ---------------------------------------- Feature #16993: Sets: from hash keys using Hash#key_set https://bugs.ruby-lang.org/issues/16993#change-111978 * Author: marcandre (Marc-Andre Lafortune) * Status: Open ---------------------------------------- To create a set from hash keys currently implies a temporary array for all keys, rehashing all those keys and rebuilding a hash. Instead, the hash could be copied and its values set to `true`. ```ruby h = {a: 1} # Now: Set.new(h.keys) # => Set[:a] # After h.key_set # => Set[:a], efficiently. ``` -- https://bugs.ruby-lang.org/
170
Age (days ago)
170
Last active (days ago)
0 comments
1 participants
participants (1)
-
nobu (Nobuyoshi Nakada)