Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Refactor HashLiteral#swap to use less temporary variables #2

Merged
merged 1 commit into from

2 participants

Dan Kubb Josep M. Bach
Dan Kubb

No description provided.

Josep M. Bach
Owner

Cool one!

Josep M. Bach txus merged commit a7bee73 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 23, 2012
  1. Dan Kubb
This page is out of date. Refresh to see the latest.
Showing with 2 additions and 5 deletions.
  1. +2 −5 lib/mutant/literal.rb
7 lib/mutant/literal.rb
View
@@ -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
Something went wrong with that request. Please try again.