[ 
https://issues.apache.org/jira/browse/GROOVY-8705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16550632#comment-16550632
 ] 

Jochen Theodorou commented on GROOVY-8705:
------------------------------------------

right now there is not really a solution for this unless we want to give the 
list/map syntax and the subscript operator different characters. Right now the 
compiler prefers the subscription and it can do really one of them.

> When add method of java.util.List is invoked with a list parameter with 
> paranthesis removed , the method fails.
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8705
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8705
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Sarath Kumar
>            Priority: Minor
>
> Consider following Groovy snippet
> def myList = [100, 200, 300]
> myList.add [400]
> println myList
> The above snippet fails with following output : 
> Caught: groovy.lang.MissingPropertyException: Exception evaluating property 
> 'add' for java.util.ArrayList, Reason: groovy.lang.MissingPropertyException: 
> No such property: add for class: java.lang.Integer
> groovy.lang.MissingPropertyException: Exception evaluating property 'add' for 
> java.util.ArrayList, Reason: groovy.lang.MissingPropertyException: No such 
> property: add for class: java.lang.Integer
> at groovyDrill1.run(groovyDrill1.groovy:2)
> If I put parenthesis around the list parameter as myList.add ([400]) , the 
> method works fine.I am new to Groovy and find the optional paranthesis 
> feature inconsistent.
> Any status updates would be greatly appreciated, thanks!
>  



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

Reply via email to