Permalink
Browse files

Merge pull request #2 from dkubb/simpify_hash_literal_mutation

Refactor HashLiteral#swap to use less temporary variables
  • Loading branch information...
2 parents 0a570bb + 0d08197 commit a7bee738c2b73bd93393acb29231bd32ce193c3d @txus committed Feb 23, 2012
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/mutant/literal.rb
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

0 comments on commit a7bee73

Please sign in to comment.