Skip to content

Commit d9e50f3

Browse files
committed
Fix ENV.each_key implementation
1 parent 6c34ed2 commit d9e50f3

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Bug fixes:
5555
* Made `Kernel#caller_locations` accept a range argument, and return `nil` when appropriate.
5656
* Made `rb_respond_to` work with primitives (#1869, @chrisseaton).
5757
* Fixed issue with missing backtrace for `rescue $ERROR_INFO` (#1660).
58+
* Fixed issue with `ENV.each_key`.
5859

5960
Compatibility:
6061

spec/tags/core/env/each_key_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/ruby/truffleruby/core/env.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,12 @@ def each
113113
end
114114
alias_method :each_pair, :each
115115

116-
def each_key(&block)
117-
@variables.each(&block)
116+
def each_key
117+
return to_enum(:each_key) { size } unless block_given?
118+
@variables.each do |name|
119+
yield set_encoding(name)
120+
end
121+
self
118122
end
119123

120124
def each_value

0 commit comments

Comments
 (0)