Feature to get or add value to an associative array.
Giles Bathgate
giles.bathgate at gmail.com
Wed Apr 18 17:19:45 UTC 2018
On Sunday, 15 April 2018 at 22:55:41 UTC, Giles Bathgate wrote:
> Time for a bikeshed discussion...
I have had some thoughts about the name and would like to share
my idea.
Firstly to summarise here are the names that have been
found/discussed so far:
C# : GetOrAdd
Java : computeIfAbsent
Python : setdefault
Rust : entry(key).or_insert_with
Jordan Wilson : getOrAdd, getOrSet
User1234 : valueOrDefault
Nicholas Wilson : getOrInsert
Steven Schveighoffer : getPtr, getRef, getInitialized
Nick Treleaven : slot
MrSmith : getOrCreate
My latest idea is just a working title, but I think I prefer it
to my original getOrAdd.
Giles Bathgate : require
My thinking is that if you `require` there to be a value in the
associative array, then you should have the ability to add one
iff it doesn't exist. It name also has parallels with the term in
other programming languages to require a module, meaning to
import it if it hasn't already been loaded.
More information about the Digitalmars-d
mailing list