Feature: `[a, b] is [c, d]`
Hello,
what would you think about a feature that converts a comparison like [a, b] is [c, d] that must be false (same for objects) to element comparisons? E.g.:
b() if ["foo", "bar"] is a()
would compile to
var _ref;
if (_ref=a(), _ref.length === 2 && _ref[0] === "foo" && _ref[1] === "bar") {
b();
}
Hmm, wondering about whether there should be a Object.keys(_ref).length === n check for object literals... maybe that could be the default for is, and {a: "foo", b: "bar"} <= obj wouldn't have that check?
edited
Same for arrays: [x, y] <= arr wouldn't have the length check
[x, y] <= arrwouldn't have the length check
- What exactly would that compile to?
- Are you proposing all binary operators should support arraywise overload?
I thought that [x, y] <= arr should compile to arr[0] === x && arr[1] === y... but that part seems like a bad idea now.