“GetOrCreate” - does that idiom have an established name?

后端 未结 5 1353
清歌不尽
清歌不尽 2021-02-12 19:51

Ok, consider this common idiom that most of us have used many times (I assume):

class FooBarDictionary
{
    private Dictionary fooBars;

          


        
5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-12 20:42

    I'm unsure of overall programming name for the high level pattern, but Perl has this wonderful behavior called Autovivification - namely, automatically creating hash (map) key with undefined value when you're querying the value of non-existing key in the hash.

提交回复
热议问题