Search code examples
data-structureshacklang

When would I use a Hack dict over a PHP array?


The docs are pretty light. The interface looks almost identical to an array.

When should I prefer a dict?


Solution

  • Arrays in php are meant to be both dictionaries and vectors. That's very confusing. Also in arrays, there is key coercion to integer. Which is more confusing.

    Hack dicts are meant to remove the ambiguity and fix the problem with the keys.