Refactor HashLiteral#swap to use less temporary variables #2

Merged
merged 1 commit into from Feb 23, 2012
View
7 lib/mutant/literal.rb
@@ -84,13 +84,10 @@ def swap
class HashLiteral < BaseLiteral
def swap
- new_body = @node.array.each_slice(2).inject([]) do |body, array|
- key, value = array
+ new_body = @node.array.each_slice(2).inject([]) do |body, (key, value)|
new_value = literal_class(value).new(value.clone).swap
- body.push key
- body.push new_value
- body
+ body << key << new_value
end
@node.array = new_body