Skip to content

Instantly share code, notes, and snippets.

@robie1373
Created November 29, 2012 19:05
Show Gist options
  • Save robie1373/4171152 to your computer and use it in GitHub Desktop.
Save robie1373/4171152 to your computer and use it in GitHub Desktop.
using srand
srand(1)
=> 42920506317323317837762064960942154151 # This is the previous value of srand
3.times { puts "-> #{a.sample}"}
-> k
-> s
-> a
srand(2)
=> 1 # This is the previous value of srand
3.times { puts "-> #{a.sample}"}
-> l
-> a
-> o
=> 3
srand(1)
=> 2 # This is the previous value of srand
3.times { puts "-> #{a.sample}"}
-> k
-> s
-> a
=> 3
srand(2)
=> 1
3.times { puts "-> #{a.sample}"}
-> l
-> a
-> o
=> 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment