Skip to content

Instantly share code, notes, and snippets.

@Narnach
Created September 22, 2009 11:30
Show Gist options
  • Select an option

  • Save Narnach/190994 to your computer and use it in GitHub Desktop.

Select an option

Save Narnach/190994 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def assert_equal(reference, value)
raise "Expected #{value.inspect} to equal #{reference.inspect}" unless reference == value
end
class Array
def remove(other)
copy = self.dup
other.each do |e|
if index = copy.index(e)
copy.delete_at(index)
end
end
copy
end
end
assert_equal [], [1,2,2] - [1,2]
assert_equal [2], [1,2,2].remove([1,2])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment