Skip to content

Instantly share code, notes, and snippets.

@psyomn
Created January 25, 2013 20:47
Show Gist options
  • Save psyomn/4637705 to your computer and use it in GitHub Desktop.
Save psyomn/4637705 to your computer and use it in GitHub Desktop.
Proc example
#
# Proc demonstration
#
my_code1 = Proc.new do
puts 1
sleep 0.5
puts 2
sleep 0.5
puts 3
end
my_code2 = Proc.new do
puts "It's a sunny day here"
print "makes me want to ... "
sleep 1
puts "Kill people"
end
my_code3 = Proc.new do
puts "Your face your face"
puts "What's wrong with your face"
end
arrcode = [my_code1,my_code2,my_code3]
order = [0, 1, 2].shuffle
puts "Order to execute:"
p order
order.each do |order|
arrcode[order].call
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment