On Mon, 15 Oct 2018 21:29:07 -0600 andrey mirtchovski <mirtchov...@gmail.com> 
wrote:
> > Unlikely :-)
> >
> > The following is much less obscure.
> >
> >     func Shuffle(slice inteface{})
> >
> > & might have more more sense. e.g.
> >
> >         var cards []card
> >         ...
> >         rand.Shuffle(cards)
>
> you've now restricted Shuffle to "shuffling" only slices. and it has

The current Shuffle is calling its func argument with indices
which make most sense for slices! What other use has it been
put to?

> to examine interface{} to determine if it's "shuffle-able". calling
> Shuffle(nil) in your example would still not do anything (which is one
> of the original issues of OP).  i posit that the current shuffle makes
> good sense given the language. metaphysics notwithstanding.

No, the interface will be examined to find a swap interface.
Something like

        rv := reflect.ValueOf(slice)
        swap = reflect.Swapper(slice)
        Shuffle(rv.Len(), swap) // current Shuffle

The same as in Sort.Slice().

All in the name of a little bit of efficiency.

-- 
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