HackerTrans
トップ新着トレンドコメント過去質問紹介求人

kotlin2

no profile record

コメント

kotlin2
·4 年前·議論
That seems really inconvenient to be honest.
kotlin2
·4 年前·議論
What languages allow such a construct? It seems like it would be super confusing if these two code samples produced different values:

    # One
    a = d["a"]["b"]["c"]
    
    # Two
    a = d["a"]["b"]
    b = a["c"]
kotlin2
·4 年前·議論
If d["a"]["b"] is 42, then how could d["a"]["b"]["c"] also be 42? What you want doesn't make sense semantically. Normally, we'd expect these two statements to be equivalent

d["a"]["b"]["c"] == (d["a"]["b"])["c"]
kotlin2
·4 年前·議論


    c = defaultdict(lambda: 42)
    b = defaultdict(lambda: c)
    a = defaultdict(lambda: b)
    a["a"]["b"]["c"]  # --> 42
kotlin2
·4 年前·議論
Now do an associative array containing another associative array.