Skip to content

Instantly share code, notes, and snippets.

@lucapette
Created April 15, 2012 14:01
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 lucapette/2392978 to your computer and use it in GitHub Desktop.
Save lucapette/2392978 to your computer and use it in GitHub Desktop.
class Array
def self.toy(n=10, &block)
block_given? ? Array.new(n,&block) : Array.new(n) {|i| i+1}
end
end
class Hash
def self.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment