Skip to content

Information on dict vs shape is unclear/incomplete/buried #1276

Open
@jwatzman

Description

@jwatzman

Where is the problem?

The pages on shapes and dicts.

What is the problem?

When to use a dict and when to use a shape is a question that IME often trips up people new to the language, especially folks coming from PHP who aren't used to thinking about those use-cases as materially different. See, for example, this SO question as a recent example which prompted this report -- but I've given the same explanation to FB bootcampers many times too.

At the very very end of the page on vec, keyset, and dict, is this note:

If you want different keys to have different value types, or if you want a fixed set of keys, consider using a shape instead.

IMO, that footnote is pretty unclear and is unlikely to help anyone who isn't already familiar with this idea, and is also a bit hard to see at the bottom of an otherwise very busy page. This idea seems to deserve its own section or even page, more than that footnote?


Please don't change anything below this point.


  • Build ID: HHVM=HHVM-4.164.0:HSL=v4.108.1:2022-07-26T17:24:38+0000:1fa47f258c6b68f8ec01899aa82fd6ffa0957109
  • Page requested: /hack/arrays-and-collections/vec-keyset-and-dict
  • Page requested at: Sun, 31 Jul 2022 15:07:23 +0000
  • Controller: GuidePageController

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions