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

Paul King commented on GROOVY-5399:
-----------------------------------

For those interested in this topic, see GROOVY-2521 and GROOVY-11143. These 
don't try to make it automatic but rather make it very simple.

> Automatically provide instance methods on objects when another class has a 
> static method with the object as first argument
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-5399
>                 URL: https://issues.apache.org/jira/browse/GROOVY-5399
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>            Reporter: Dr. Russel Winder
>            Assignee: Jochen Theodorou
>            Priority: Major
>
> The script:
> {code}
> number = 27
> println number.toHexString ( )
> {code}
> results in the message:
> {quote}
> Caught: groovy.lang.MissingMethodException: No signature of method: 
> java.lang.Integer.toHexString() is applicable for argument types: () values: 
> []
> Possible solutions: toHexString(int), toString(), toString(), toString(), 
> toString(int), toString(int, int)
> groovy.lang.MissingMethodException: No signature of method: 
> java.lang.Integer.toHexString() is applicable for argument types: () values: 
> []
> Possible solutions: toHexString(int), toString(), toString(), toString(), 
> toString(int), toString(int, int)
>       at toHexString_Problem.run(toHexString_Problem.groovy:5)
> {quote}
> The reason is that _toHexString_ is defined as a static method on the types 
> and not within the GroovyJDK. I believe that it is more usable for 
> prograqmmers, more appropriate to a dynamic language, and generally more 
> Groovy to allow the method to operate on a reference to an object and only 
> raise an exception if the object is not of an appropriate type. 



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

Reply via email to