Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0, 1.1-beta-1, 1.1-beta-2, 1.1-beta-3
-
None
-
None
Description
This is an old bug.
Case 1)
groovy> String str= "hello 10"
groovy> str as String[]
Result: ["h", "e", "l", "l", "o", " ", "1", "0"]
That is, an array of String with one element per character in the original String.
Case 2)
groovy> def i= 10
groovy> def gstr= "hello $i"
groovy> gstr as String[]
Result: ["hello 10"]
That is, an array of String, with only one element consisting of the whole rendered String.
This is inconsistent behaviour and may give undesired results when calling methods that expect an array of String