с рандомом у вас мутабельный стейт получается, который виден на ружу по сути, т.е. его изменения видны программе, а то что внутрях коллекции происходит оно там и остается, как в вегасе, для внешнего мира ни че не меняется
In computer science, an operation, function or expression is said to have a side effect if it modifies some state variable value(s) outside its local environment, that is to say has an observable effect besides returning a value (the intended effect) to the invoker of the operation.