3 ms·
While I also recoil at the $, I much prefer a functional programming style based on immutable objects. Defaulting to in-place mutation would ruin the API. I pr
by stickfigure 11y ago
While I also recoil at the $, I much prefer a functional programming style based on immutable objects. Defaulting to in-place mutation would ruin the API.
I probably would have gone with shuffleInPlace(), but the more I think about it, the more I like the $. Especially since it will rarely get used.
This library is pretty neat largely because it changes some common (and annoying) java idioms.
- jdmichal 11y agoIn that case, have shuffle() always return a new copy, and there is no in-place shuffle. I would consider this a good solution, assuming that the loss of an in-place shuffle is acceptable. (This would basically be the .NET LINQ approach.)
- stickfigure 11y agoFor a really class act, check out Ceylon's collection classes. As an example, Set and SetMutator are separate interfaces; a MutableSet has both. The whole standard library is really well thought out WRT typesafe functional programming.