groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ahm Avoby <aliencheck...@gmail.com>
Subject Re: [VOTE]About the Union Type for method/constructor declaration
Date Sun, 23 Jul 2017 15:21:42 GMT
This is a feature I could see myself using immediately, so +1 from my side.

Maybe call it "Intersection Types" or "Common Denominator Types", to
seperate it from much more complex type pattern matching support ?

Daniel Sun <realbluesun@hotmail.com> schrieb am So., 23. Juli 2017, 00:28:

> Hi all,
>
>        I've been thinking about Union Type for method/constructor
> declaration. It is similar to multi-catch in try-catch statement, e.g.
>
> class UnionTypeSample {
>   public UnionTypeSample(A|B|C p) {
>      // do something
>   }
>
>   def m(D|E p) {
>     // do something
>   }
> }
>
>       Groovy will translate the above code into the following code, which
> is
> also the same way how multi-catch is handled.
>
> class UnionTypeSample {
>   public UnionTypeSample(A p) {
>      // do something
>   }
>
>   public UnionTypeSample(B p) {
>      // do something
>   }
>
>   public UnionTypeSample(C p) {
>      // do something
>   }
>
>   def m(D p) {
>     // do something
>   }
>
>   def m(E p) {
>     // do something
>   }
> }
>
>      Any thoughts?
> ----------------------------------
>   [+1] I like it
>   [  0] Not bad
>   [-1] I do not like it
> ----------------------------------
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context:
> http://groovy.329449.n5.nabble.com/VOTE-About-the-Union-Type-for-method-constructor-declaration-tp5742265.html
> Sent from the Groovy Users mailing list archive at Nabble.com.
>

Mime
View raw message