Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #2 from dkubb/simpify_hash_literal_mutation

Refactor HashLiteral#swap to use less temporary variables
  • Loading branch information...
commit a7bee738c2b73bd93393acb29231bd32ce193c3d 2 parents 0a570bb + 0d08197
Josep M. Bach authored February 22, 2012

Showing 1 changed file with 2 additions and 5 deletions. Show diff stats Hide diff stats

  1. 7  lib/mutant/literal.rb
7  lib/mutant/literal.rb
@@ -84,13 +84,10 @@ def swap
84 84
 
85 85
     class HashLiteral < BaseLiteral
86 86
       def swap
87  
-        new_body = @node.array.each_slice(2).inject([]) do |body, array|
88  
-          key, value = array
  87
+        new_body = @node.array.each_slice(2).inject([]) do |body, (key, value)|
89 88
           new_value = literal_class(value).new(value.clone).swap
90 89
 
91  
-          body.push key
92  
-          body.push new_value
93  
-          body
  90
+          body << key << new_value
94 91
         end
95 92
 
96 93
         @node.array = new_body

0 notes on commit a7bee73

Please sign in to comment.
Something went wrong with that request. Please try again.