Actions
Feature #16182
closedShould `expr in a, b, c` be allowed or not?
Feature #16182:
Should `expr in a, b, c` be allowed or not?
Description
In #15865, a new syntax <expr> in <pattern> was introduced. By using this, we can write:
json = { foo: 1, bar: 2}
if json in { foo:, bar: }
p [foo, bar] #=> [1, 2]
end
However, we cannot write:
p(json in { foo:, bar: }) #=> expected: true, actual: syntax error
This is because <expr> in <pattern> is an expression but not an argument. For example, foo(json in a, b, c) is ambiguous: it is considered foo((json in a), b, c) and foo((json in a, b, c)).
What should we do?
- Do nothing; we admit that it is a spec
- Revert the feature
- Disallow a pattern like
a, b, cora:, b:, c:in this one-line pattern matching syntax; we ask a user to writejson in [a, b, c]orjson in {a:, b:, c:}
Actions