You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Saravanan Palanichamy <ch...@gmail.com> on 2023/03/20 05:39:43 UTC

Closure params hint

Hello Everyone

   I am trying to define a method that will take a closure whose parameters
are a generic type based on generic parameters on the function. The closure
returns void

class Result<K, V> {
>     public Map<K, V> pairs;
> }
>
> class MyOtherClass {
>     // This closure takes an input of Result<T1, T2>
>     static <T1, T2> void make(@ClosureParams(...) Closure<Void> myClosure) {}
> }
>
>
>
I am trying to understand what to use in closure params. I tried

> @ClosureParams(FromString, options = "com.myGroovy.model.Results<I, R>")
>
> But this resulted in Results<Object, String> instead of <String, String>
as shown below

[image: Screenshot 2023-03-20 at 11.09.00 AM.png]

Any ideas on how to define this?


regards