Created
January 25, 2013 20:47
-
-
Save psyomn/4637705 to your computer and use it in GitHub Desktop.
Proc example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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