Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Refactor HashLiteral#swap to use less temporary variables #2

Merged
merged 1 commit into from
Feb 23, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions lib/mutant/literal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down