zio / zio-direct

Direct-Style Programming for ZIO
https://zio.dev/zio-direct
155 stars 13 forks source link

Mutable collection usage #24

Open jetjager opened 1 year ago

jetjager commented 1 year ago

The following code triggers a 'Detected the use of a mutable collection inside a defer clause.', but I don't think it should lead to any issues.

defer {
    val text = ZIO.succeed("1,2,3").run
    val values = text.split(",").toList
    ZIO.foreach(values)(v => zio.Console.printLine(v))
  }
deusaquilus commented 1 year ago

The text.split(",") call returns a Java array I.e mutable. I’m thinking that maybe I should relax the rules for Array because there is only one real mutation operator on it (I.e set-at-index) which I could check for.