groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Sun <realblue...@hotmail.com>
Subject [VOTE]About the Union Type for method/constructor declaration
Date Sat, 22 Jul 2017 22:28:07 GMT
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