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

Eric Milles closed GROOVY-9421.
-------------------------------
    Resolution: Information Provided

> Ternary operator in a property assignment
> -----------------------------------------
>
>                 Key: GROOVY-9421
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9421
>             Project: Groovy
>          Issue Type: Bug
>          Components: Groovy Console, groovy-runtime
>    Affects Versions: 2.4.18
>            Reporter: gekm
>            Priority: Major
>
> Why ternary operator in properties works incorrectly with strings?
> {code:groovy}
> class Parent {
>     def String name = (name == null || name == 'somebadname') ? 'default' : 
> name
> }
> a = new Parent()
> println("name is: ${a.name}")
> b = new Parent(name: 'somebadname')
> println("name is: ${b.name}")
> c = new Parent(name: 'other')
> println("name is: ${c.name}")
> {code}
> output:
> {code:java}
> name is: default
> name is: somebadname
> name is: other
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to