Skip to content

Instantly share code, notes, and snippets.

@semaperepelitsa
Forked from lucapette/toys.rb
Created March 6, 2011 17:29
Show Gist options
  • Save semaperepelitsa/857436 to your computer and use it in GitHub Desktop.
Save semaperepelitsa/857436 to your computer and use it in GitHub Desktop.
def Array.toy(n=10,&block)
if block_given?
new(n, &block)
else
new(n) {|i| i+1}
end
end
def Hash.toy(n=10)
Hash[Array.toy(n).zip(Array.toy(n){|c| (96+(c+1)).chr})]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment