Mutable type return problem

Here is my simple example

I define a map of mutable collection of dictionaries.

Normal business changeMap is normal modification.

But in getMap, if I need to return this data. I need to redefine an immutable dictionary collection and return it.

This way of writing is very unfriendly. Is there any way to directly turn the entire collection into an immutable one.
So far I haven’t found a way, the Array has the kind I want. Freeze, thaw, but only for Array.

This example only shows 4 attributes. If the business is too large, there are more than a dozen, and the business code at this time is very cumbersome.

I would advise to have some var collection that you can add/append Maps to. Then you don’t need var fields in the record.

This post was flagged by the community and is temporarily hidden.