Skip to content

Commit e36724c

Browse files
committed
Reuse Data#initialize logic for Data#with
* Including the String => Symbol coercion
1 parent 25685a3 commit e36724c

File tree

1 file changed

+1
-9
lines changed
  • src/main/ruby/truffleruby/core

1 file changed

+1
-9
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,7 @@ def to_h(&block)
127127
def with(**changes)
128128
return self if changes.empty?
129129
130-
h = to_h
131-
changes.each_pair do |key, value|
132-
if h.include?(key)
133-
h[key] = value
134-
else
135-
raise ArgumentError, Truffle::DataOperations.unknown_keywords_message(changes.keys, self)
136-
end
137-
end
138-
Primitive.class(self).new(**h)
130+
Primitive.class(self).new(**to_h.merge(changes))
139131
end
140132
141133
def inspect

0 commit comments

Comments
 (0)