Project

General

Profile

Actions

Feature #16993

open

Sets: from hash keys using Hash#key_set

Feature #16993: Sets: from hash keys using Hash#key_set

Added by marcandre (Marc-Andre Lafortune) over 5 years ago. Updated 7 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:98968]

Description

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.

h = {a: 1} # Now: Set.new(h.keys) # => Set[:a] # After h.key_set # => Set[:a], efficiently. 

Related issues 1 (1 open0 closed)

Actions

Also available in: PDF Atom