I worked in a proprietary language a few years back which had a nice feature in its hash table implementation. When I create the hash table, I specify the value which should be returned when accessing a key not in the table. This was often useful. For example, if the hash table values are integers, it often makes sense to have 0 returned as default.
Is there some Map-like container in Scala which has this feature.
The closest thing that I know of is that I can use
.getOrElse(key,default) which allows every call-site to specify a default value. It would sometimes make the code cleaner, if I could specify that default value at object construction time.