Skip to content
This repository was archived by the owner on Jul 13, 2025. It is now read-only.
This repository was archived by the owner on Jul 13, 2025. It is now read-only.

TryGet trait (Get() with default value) #166

Open

Description

@koraa

Rename the Get trait to TryGet; the signature should be tryGet(key, default).
We can derive from this:

const get = (c, k) => {
  const none = Symbol();
  const r = tryGet(c, k, none);
  assert(r !== none, "No such element");
  return r;
};

const has = (c, k) => {
  const none = Symbol();
  return tryGet(c, k, none) !== none;
}

Edit: This is a breaking change.

Activity

  1. added
    enhancement
    on Mar 11, 2021
  2. added
    breaking-change
    on Apr 30, 2021
  3. changed the title [-]Get should take a default value[/-] [+]TryGet trait (Get() with default value)[/+] on Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking-changeenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions