You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Jochen Theodorou (JIRA)" <ji...@apache.org> on 2019/01/13 13:15:00 UTC

[jira] [Updated] (GROOVY-8956) conditional if/else has issues with evaluated strings in maps

     [ https://issues.apache.org/jira/browse/GROOVY-8956?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jochen Theodorou updated GROOVY-8956:
-------------------------------------
    Priority: Minor  (was: Critical)

> conditional if/else has issues with evaluated strings in maps
> -------------------------------------------------------------
>
>                 Key: GROOVY-8956
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8956
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-jdk
>    Affects Versions: 2.5.0, 2.5.2, 2.5.4, 2.5.5
>         Environment: Ubuntu, Sun Java 8
>            Reporter: Owen Rubel
>            Priority: Minor
>
> I was converting an if/else to a conditional and had the following error:
> class org.codehaus.groovy.ast.expr.TernaryExpression, with its value '((codeTotals[$it[1]] == null)) ? 0 : codeTotals[$it[1]]', is a bad expression as the left hand side of an assignment operator at line: 50 column: 87. 
> My if/else (which works)is as follows:
> if(codeTotals["${it[1]}"]==null){
>  codeTotals["${it[1]}"] = 0
> }else{
>  codeTotals["${it[1]}"] += 1
> }
>  
> ... VS the  logical conditional (which throws the error):
> codeTotals["${it[1]}"] = (codeTotals["$it[1]"] == null) ? 0 : codeTotals["$it[1]"] +=1
>  
> Right now I am just trying to test some features but I thought this was weird enough to mention since a logical should work the same regardless of variable.
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)