Skip to content

Instantly share code, notes, and snippets.

@dreamr
Created November 30, 2010 19:14
Show Gist options
  • Save dreamr/722201 to your computer and use it in GitHub Desktop.
Save dreamr/722201 to your computer and use it in GitHub Desktop.
array.rb
class Array
def to_hash
begin
raise ArgumentError if self.collect {|x| x.flatten.size > 2}.reject {|x| x == false}.size > 0
Hash[*self.flatten]
rescue NoMethodError
raise ArgumentError
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment