Skip to content

Instantly share code, notes, and snippets.

@StanBright
Created May 6, 2010 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StanBright/392035 to your computer and use it in GitHub Desktop.
Save StanBright/392035 to your computer and use it in GitHub Desktop.
class Array
def to_hash
hash = Hash.new
for pair in self
if ( pair.size == 2 and
pair[0].class == Symbol and
pair[1].class == Fixnum )
hash[pair[0]] = pair[1]
else
raise ArgumentError.new "Incorrect array type"
end
end
hash
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment