23
Comments
  • 0
    What datatype is the key? Or are those multiple keys?
  • 11
    python can use any immutable as keys for dicts.
  • 2
    Oh boy, if you like pattern matching, you're gonna love elixir
  • 1
    @Awlex what’s that? Ok googled it but too tired to dive into , thanks for pointing it out thou
  • 0
    @refi64 well I used such tuple to describe similarities for event records, so once there was match I’m able to append IDs into each list
  • 4
    I must be missing something... what blew your mind exactly?
  • 6
    Dictionary using tuple as index refering to empty list. Nothing special :p
  • 3
    @refi64 pattern matching is like switch/case on steroids. Erlang (and elixir) allow to match cases based on complex statements, like (looking at python) tuples. If VERY effective tool.
  • 1
    @kenogo Oh, I thought that was Javascript xD
  • 2
    @mt3o @user261
    exactly that a key can be tuple, I’m python noob therefore that mindblow :D
  • 1
    @kLue to give you a glimpse of what happens in lower level, is not technically an index. Rather a pair of items, index+value. So the index can be anything. For consistency, it has to be immutable.
    For example in java world, you have maps, hashmap in particular, where everything can be the key. The key is stored as reference, but it's organized by objects hash, not real value.
    I guess you are amazed became you are used to arrays from C, where array is pointer to the address in the memory and has to be used together with index (shift from the blocks start).
  • 0
    @mt3o thx for this insight man !! 💆‍♂️
  • 0
    Dont c a problem
Add Comment