Hi,
i want to create singleton map object to store keys and values, but it is not working as static, as i go on add the key value pair it is not increasing map size , it is still one
Hi,
i want to create singleton map object to store keys and values, but it is not working as static, as i go on add the key value pair it is not increasing map size , it is still one
Default map is immutable.
What you describe would look something like this
object GlobalMutableState {
val keysandvalues: scala.collection.mutable.Map[Any, Any] = scala.collection.mutable.Map.empty
}
As a word of warning, having global mutable state is a red flag, as is having untyped values (Any
). This is firing all alarm bells. It may be good to consider a different solution strategy.