https://kotlinlang.org logo
#announcements
Title
# announcements
a

alien11689

08/27/2017, 5:19 PM
@Danilo Herrera 1) Why did you use MutableCollection? Do you really need mutability? 2) As user of your function I would prefer receiving LotteryResult(...) from pickLottery function, not String. 3) I will add configurable seed for random for future testing 4) Are extension functions really needed? I would prefer e. g. private fun takeRandom(set, count): LotteryState -> LotteryState(setWithoutPicked, pickedNumbers) 5) mayble your functions should be inside class Lottery and only pickLottery should be public?
d

Danilo Herrera

08/27/2017, 5:27 PM
Hi Dominic, thank you for your comments! 1) I used mutable sets to remove the number from the set so that it cannot be picked again. Also, to add to the set of picked numbers. 2) Good point. LotteryResult would allow for extensibility 3) Hmm, I didn't think about adding a configurable seed for testing. Thanks! 4) I guess extension functions are not really needed. I'll explore another solution without extension functions. 5) I'll try containing the Lottery pick in its own class
4 Views