[ https://issues.apache.org/jira/browse/GROOVY-8956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16741574#comment-16741574 ]
Jochen Theodorou commented on GROOVY-8956: ------------------------------------------ this should be:{code:Java}codeTotals["${it[1]}"] = (codeTotals["$it[1]"] == null) ? 0 : (codeTotals["$it[1]"] +=1){code} > 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)