You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2023/07/12 01:22:00 UTC
[jira] [Commented] (GROOVY-3520) Support true optional parameters.
[ https://issues.apache.org/jira/browse/GROOVY-3520?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17742224#comment-17742224 ]
Paul King commented on GROOVY-3520:
-----------------------------------
I am not sure I'd call this "fixed" if by "true" optional parameters we mean that the @NamedParams and Map-based methods (or some alternative implementation) was not visible to the Groovy developer. Having said that, happy to close this for now since GROOVY-8451 seems to duplicate the issue enough.
> Support true optional parameters.
> ---------------------------------
>
> Key: GROOVY-3520
> URL: https://issues.apache.org/jira/browse/GROOVY-3520
> Project: Groovy
> Issue Type: New Feature
> Affects Versions: 1.6.2
> Reporter: sukhyun.cho
> Priority: Major
>
> Currently, there is no way of calling a method with sparse optional parameters that are not sequential with respect to the order in which the parameters are declared.
> Python offers this flexibility, and it makes sense that Groovy allow it, too. When implemented, the following would be expected to pass:
> {code}
> public def foo(int a, int b = 42, int c = 314)
> {
> return [a, b, c]
> }
> // the following two cases pass, atm.
> assert foo(1) == [1, 42, 314]
> assert foo(1, 2) == [1, 2, 314]
> // the following three cases fail, atm.
> assert foo(1, b: 2) == [1, 2, 314]
> assert foo(1, c: 3) == [1, 42, 3]
> assert foo(1, b: 2, c: 3) == [1, 2, 3]
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)