Skip to content

Commit 1ba5d8e

Browse files
committed
[GR-20432] Implement ENV.slice method.
PullRequest: truffleruby/1241
2 parents 15cff65 + 3581127 commit 1ba5d8e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ Compatibility:
8989
* Implemented `-n` CLI option (#1532).
9090
* Cache the `Symbol` of method names in call nodes only when needed (#1872).
9191
* Implemented `rb_get_alloc_func` and related functions (#1874, @XrXr).
92+
* Implemented `rb_module_new`, `rb_define_class_id`, `rb_define_module_id`, (#1876, @chrisseaton).
93+
* Implemented `ENV.slice`.
9294

9395
Performance:
9496

spec/tags/core/env/slice_tags.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,17 @@ def rassoc(value)
315315
key ? [key, value] : nil
316316
end
317317

318+
def slice(*keys)
319+
result = {}
320+
keys.each do |k|
321+
value = lookup(k)
322+
unless value.nil?
323+
result[k] = value
324+
end
325+
end
326+
result
327+
end
328+
318329
def set_encoding(value)
319330
return unless value.kind_of? String
320331
if Encoding.default_internal && value.ascii_only?

0 commit comments

Comments
 (0)