HackerTrans
TopNewTrendsCommentsPastAskShowJobs

kotlin2

no profile record

comments

kotlin2
·há 4 anos·discuss
That seems really inconvenient to be honest.
kotlin2
·há 4 anos·discuss
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
·há 4 anos·discuss
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
·há 4 anos·discuss


    c = defaultdict(lambda: 42)
    b = defaultdict(lambda: c)
    a = defaultdict(lambda: b)
    a["a"]["b"]["c"]  # --> 42
kotlin2
·há 4 anos·discuss
Now do an associative array containing another associative array.