mroth / weightedrand

:balance_scale: Fast weighted random selection for Go
MIT License
393 stars 50 forks source link

implement NewChoice convenience constructor #1

Closed mroth closed 4 years ago

mroth commented 4 years ago

This is not in itself a huge convenience currently, however based on a toy implementation utilizing the latest go2 generics draft, it will end up being more ergonomic to use a constructor in this fashion where the type of T can be inferred rather than having to specify the type via a Choice(type T) literal.