[
https://issues.apache.org/jira/browse/GROOVY-8551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16444125#comment-16444125
]
Paul King commented on GROOVY-8551:
-----------------------------------
It was these edge cases I mentioned in the email Daniel referred to:
{code}
Closure[] x = { -> 1 + 1 }
assert x[0].call() == 2
Closure[] y = { {-> 1 + 1 } }
assert y[0].call().call() == 2
{code}
Groovy currently "coerces" the single Closure in the first example into a
Closure array and with that logic in place, the second example becomes a
closure array with a single element which is a closure (the outer braces) which
returns a closure (the inner braces) when called. With a mindset of "curly
braces is always a closure" that makes perfect sense but if the outer curly
braces is now also meant for an array, I think most of us would expect the
second example to just be an array with a single closure in it.
So, this is obviously a breaking change and would be mirrored in the
multi-dimension case too but it's arguably an edge case (only affects closures
and not other classes) and perhaps a not widely used style. So we need to
consider it a little more carefully and if we agree that we don't care about
the breaking change, we certainly would need to document it.
> Parrot Parser: support multi-dimensional array initializers
> -----------------------------------------------------------
>
> Key: GROOVY-8551
> URL: https://issues.apache.org/jira/browse/GROOVY-8551
> Project: Groovy
> Issue Type: Improvement
> Affects Versions: 2.6.0-alpha-3, 3.0.0-alpha-2
> Reporter: Eric Milles
> Assignee: Daniel Sun
> Priority: Minor
>
> GROOVY-3791 indicates support for Java-style array initializer is now
> supported by Parrot Parser. However, a compact multi-dimensional initializer
> still fails:
> {code:groovy}
> def strings = new String[][] { { "a", "b", "c" }, { "1", "2", "3" } }
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)