How does one generate a random number in Apple's Swift language?

后端 未结 25 1896
有刺的猬
有刺的猬 2020-11-22 09:51

I realize the Swift book provided an implementation of a random number generator. Is the best practice to copy and paste this implementation in one\'s own program? Or is t

25条回答
  •  一生所求
    2020-11-22 10:10

     let MAX : UInt32 = 9
     let MIN : UInt32 = 1
    
        func randomNumber()
    {
        var random_number = Int(arc4random_uniform(MAX) + MIN)
        print ("random = ", random_number);
    }
    

提交回复
热议问题