Skip to content

Commit 687277b

Browse files
committed
[GR-20429] Fix ENV.each_key implementation.
PullRequest: truffleruby/1238
2 parents 9b8b857 + d9e50f3 commit 687277b

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
@@ -65,6 +65,7 @@ Bug fixes:
6565
* Removed "shadowing outer local variable" warning.
6666
* Fixed parameter conversion to `String` in ENV methods.
6767
* Fixed deprecation warning when `ENV.index` is called.
68+
* Fixed issue with `ENV.each_key`.
6869

6970
Compatibility:
7071

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)