Skip to content

Instantly share code, notes, and snippets.

@earlonrails
Created October 21, 2011 21:01
Show Gist options
  • Save earlonrails/1304948 to your computer and use it in GitHub Desktop.
Save earlonrails/1304948 to your computer and use it in GitHub Desktop.
swap a and b without global variables and only 2 local vars
def swap(a,b)
a = a + b
b = a - b
a = a - b
return {:a => a, :b => b}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment