本文翻译自:How does one generate a random number in Apple's Swift language?
I realize the Swift book provided an implementation of a random number generator. 我意识到Swift书提供了随机数生成器的实现。 Is the best practice to copy and paste this implementation in one's own program? 最好的做法是将此实现复制并粘贴到自己的程序中吗? Or is there a library that does this that we can use now? 或者是否有一个我们现在可以使用的库?
#1楼
参考:https://stackoom.com/question/1cjLl/如何在Apple的Swift语言中生成一个随机数
#2楼
I've been able to just use rand()
to get a random CInt. 我已经能够使用rand()