Is there any “good” code template for initializing and filling in closed modified Maps Class, and then exposing them unchanged? Or should I just forever regret my functional misconduct in such cases?
In a certain class, I initialize some Maps as mutable, since the logic of their initialization does not fit very naturally, in this case using a pure mutable approach to creation. Or, I was just lazy to simulate it invariably.
Now I get Scala ugly code - after calculating the initialization, I copy the converted modified Maps to immutable (mainly through .toMap). This is already ugly, because (1) the code has dual Maps, and double naming does not work a bit, and (2) the conversion lines look more attractive than I hope.
Additionally (3), to my dislike that the type definitions of received immutable Maps can now only be at the bottom of the code, since they can only be declared after calculating the initialization (or can they lazygo to the beginning? Is still not entirely elegant )
Any way to elegantly wrap around a modified card initialization code?
source
share