Hi all,
As we all know, Java array is one of features widely applied in Java
projects. In order to improve the compatibility with Java(Copy & Paste). The
PR[1] will make Groovy support java-like array and make the differences[2]
with Java less and less, e.g.
*One-Dimensional array*
```
String[] names = {'Jochen', 'Paul', 'Daniel'}
```
*Two-Dimensional array*
```
int[][] data = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9},
new int[] { 10, 11, 12 },
{13, 14, 15}
}
```
*Annotation array*
```
@PropertySources({
@PropertySource("classpath:1.properties"),
@PropertySource("file:2.properties")
})
public class Controller {}
```
*More examples*
Please see the examples on the PR page[1]
*Known breaking changes*
1. Closure array in the dynamic mode
Before
```
Closure[] y = { {-> 1 + 1 } }
assert y[0].call().call() == 2
```
After
```
Closure[] y = { {-> 1 + 1 } }
assert y[0].call() == 2
```
2. String array in the dynamic mode
Before
```
String[] a = {}
assert 1 == a.length
assert a[0].contains('closure')
```
After
```
String[] a = {}
assert 0 == a.length
```
If Groovy 3 supports Java-like array, what do you think about the new
feature? Do you like it? We need your feedback. Thanks in advance!
[+1] I like it
[ 0] Not bad
[-1] I don't like it, because...
Cheers,
Daniel.Sun
[1] https://github.com/apache/groovy/pull/691
[2] http://groovy-lang.org/differences.html
--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html