You assign 'b' as an Array, and arrays works differently than lists. Arrays are bound to their length, so 'a[2]' should report out of bounds as it is not 3 elements long, whereas a list b[2] would report null
IMO it's working as intended. Den tors. 6. feb. 2025 kl. 10.20 skrev OCsite <o...@ocs.cz>: > Hi there, > > is this inconsistence intentional and the proper Groovy behaviour, or is > that a bug and should I add a jira ticket? > > Thanks! > > === > > *groovy:*000*>* a=[1,2] > > *===>* [1, 2] > > *groovy:*000*>* b=a as Object[] > > *===>* [1, 2] > > *groovy:*000*>* a[2] > > *===>* null > > *groovy:*000*>* b[2] > > *ERROR* java.lang.ArrayIndexOutOfBoundsException: > > *Index 2 out of bounds for length 2* > > *groovy:*000*>* > === > -- Med venlig hilsen, Søren Berg Glasius Hedevej 1, Gl. Rye, 8680 Ry Mobile: +45 40 44 91 88 --- Press ESC once to quit - twice to save the changes.