Hi I'm making a simple function to generate a float array in ascending order but i want to know if there is a simpler way to do this.
So far this is my code
#initialice the array
x0 = []
#insert the values 5 times
5.times do
#random float generator
value=rand(0.1..50.1)
x0<<value
end
#values arranged in ascending order
x0.sort!
#printing the array
puts "lista x0" +x0.to_s
Aucun commentaire:
Enregistrer un commentaire