Details
-
Improvement
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
It seems like Groovy should be able to handle "Case 5" below,
but instead it reports a compile-time error.
//----------------------- // Case 1: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 2: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 3: OK //----------------------- bar = 0 ? "moo" : "cow" //----------------------- // Case 4: OK //----------------------- bar = 0 ? "moo" : "cow" //--------------------------------------------------- // Case 5: ERROR. // // Compiler says: // expecting ':', found '<newline>' //--------------------------------------------------- bar = 0 ? "moo" : "cow" //----------------------------------------------------- // Case 6: OK // // Groovy cannot figure out that this is a // valid ternary without the help of the '\' // line continuation escape. How come? // //----------------------------------------------------- bar = 0 ? "moo" \ : "cow"
Attachments
Issue Links
- is duplicated by
-
GROOVY-4464 Loosen white space restrictions
- Closed