E
Eustaquio 'TaQ' Rangel
Hi.
I just tested on one machine, but seems that if we make some call to
rand before using Array#choice we can have better random values, check
it out:
# choice.rb
a = (1..10).to_a
3.times { puts a.choice }
[taq@~/code/ruby]ruby choice.rb
5
5
1
[taq@~/code/ruby]ruby choice.rb
9
10
2
[taq@~/code/ruby]ruby choice.rb
9
10
2
Inserting rand:
# choice.rb
a = (1..10).to_a
rand
3.times { puts a.choice }
[taq@~/code/ruby]ruby choice.rb
6
8
6
[taq@~/code/ruby]ruby choice.rb
3
8
4
[taq@~/code/ruby]ruby choice.rb
6
2
10
Is there any recommendation to call rand before using choice?
Thanks.
I just tested on one machine, but seems that if we make some call to
rand before using Array#choice we can have better random values, check
it out:
# choice.rb
a = (1..10).to_a
3.times { puts a.choice }
[taq@~/code/ruby]ruby choice.rb
5
5
1
[taq@~/code/ruby]ruby choice.rb
9
10
2
[taq@~/code/ruby]ruby choice.rb
9
10
2
Inserting rand:
# choice.rb
a = (1..10).to_a
rand
3.times { puts a.choice }
[taq@~/code/ruby]ruby choice.rb
6
8
6
[taq@~/code/ruby]ruby choice.rb
3
8
4
[taq@~/code/ruby]ruby choice.rb
6
2
10
Is there any recommendation to call rand before using choice?
Thanks.