You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Could anyone clarify the difference between these two?
r := rand.New(rand.NewSource(...))
var r rand.Rand; r.Seed(...)
Ian Lance Taylor
unread,
Mar 26, 2019, 6:25:41 PM3/26/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Liam Breck, golang-nuts
Well, it's not a complete program, and maybe I'm missing something,
but it seems to me that the difference is that the first one will give
you a random number generator and the second one will panic at run
time.
Ian
jake...@gmail.com
unread,
Mar 27, 2019, 11:54:38 AM3/27/19
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Following up on Ian's post. It is generally a good idea to go to the playground and make a minimal working "program" to demonstrate your question before posting. In doing so you would have discovered that the zero value of a rand.Rand can not be used, and will panic.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to dja...@gmail.com, golang-nuts
I don't think there is any meaningful difference between those two.
Ian
prrat...@gmail.com
unread,
Feb 10, 2020, 12:09:12 PM2/10/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
Seed initialise default resource once for random method and using NewSource create different resources for random method
anderson...@blacklane.com
unread,
Feb 11, 2020, 4:02:19 AM2/11/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
If you use the same seed the source will output the same pseudo-random output. Which is quite useful when you need to be able to replay/predict the random behaviour