what is your version to this problem ? i'm doing so:
array = [1,2,3,4,5,6,7,8,9]
puts array.sort_by { array }.first
puts array[rand(array.size)]
puts array.shuffle.first
puts array.sample
what is your version to this problem ? i'm doing so:
array = [1,2,3,4,5,6,7,8,9]
puts array.sort_by { array }.first
puts array[rand(array.size)]
puts array.shuffle.first
puts array.sample
I use array.sample
. It is MUCH easier to read than the first 2 and slightly easier to read than the third.