Skip to content

Instantly share code, notes, and snippets.

@oddlyzen
Forked from lucapette/toys.rb
Created February 13, 2014 18:21
Show Gist options
  • Save oddlyzen/8980758 to your computer and use it in GitHub Desktop.
Save oddlyzen/8980758 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