https://kotlinlang.org logo
#feed
Title
# feed
c

Casey Brooks

08/16/2022, 6:30 PM
I’m not sure if anyone else has ever needed an instance of
Random
that’s immutable, but here you go. https://gist.github.com/cjbrooks12/cbe7e515ecfd75d63ca68db42da3a41b
This is useful for programming with the MVI model, such as with #compose or when using the ballast MVI library. The default
Random
implementation is mutable internally, which can cause problems when your framework needs things to be immutable to work properly.
e

ephemient

08/16/2022, 6:37 PM
IMO keeping the
Random
interface is a mistake
c

Casey Brooks

08/16/2022, 6:48 PM
There’s a lot of detail in the
Random
base class, plus a bunch of extension functions, that I didn’t want to copy. It could be confusing since it changes the behavior to be incompatible with the standard
Random
, but for my needs this is sufficient. And that’s why I just posted this as a gist rather than publishing it as a full library
a

altavir

08/17/2022, 6:23 AM
3 Views