How to create a mass of substance chips with an early value in aid of the heterators



  • Cycles can be used in Ruby to create massive accidental values. And then the code would look like,

    n = 10
    a = []
    rnd = Random.new
    index = 0 
    while index < n
        p a[index] = rnd.rand(-10.99..10.99)
        index += 1
    end
    

    I can't figure out how to achieve that result with the help of the heterans.



  • Try this:

    a = 10.times.map{ Random.rand(-10.99..10.99) }
    

    a It's gonna be the right mass.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2