Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.0-JSR-4
-
Fix Version/s: 1.0-JSR-5
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
Let's say I have a method that receives a string that contains an integer (0..9). If I use that parameter as part of a range, Groovy considers it a character which causes some really unexpected effects. For example:
str = "5"
// ...
lastNumber = str;
myRange = 0..lastNumber
myRange.each {
print it
}
I would expect it to print: 012345
Instead it takes the character value of 5 and prints: 0123456789101112 ... 515253
Is this what is really wanted or should this be considered a bug? At least it makes it pretty easy to make mistakes.
Actually this is not specific to ranges. Groovy seems to consider a string whose length is one as a character. I guess there is nothing that can be done about that? I would just have to say: "lastNumber = str.toInteger()"?