Hi;

To shuffle items in a slice I'm doing this:

var res []Item

//fill res logic

shuffle := make(map[int]*Item)
for k, v := range res {
 shuffle[k] = &v
}
res = nil
for _, v := range shuffle {
 res = append(res, *v)
}

Which inserts items into a map then ranges over that map. Ranging over a 
map in Go returns the items in random order.

1 - I thought it's a cool trick!
2 - Is anything bad about doing this?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to