ferrum
ferrum copied to clipboard
TryGet trait (Get() with default value)
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.