Nice TWiki > Dev > FeatureProposals > TupleFunctionDeclaration TWiki webs:
Dev | Doc | Main | TWiki | Sandbox
Dev . { Changes | Index | Search | Go }
This page describes the feature request to use tuple types in function declarations and anonymous functions.

The following code shows the currently working way. The new feature is commented out.

package test;
import java.util.*;
void main(String[] args) {
  List<(String, String)> tuples = new ArrayList();

  tuples.add(("a", "1"));
  tuples.add(("b", "2"));

  //   works fine
  tuples.foreach((String, String) tuple => {
      (String letter, String number) = tuple;
      println("letter: "+letter+" number: "+number);
    }
  );

  /*
  //   does not compile
  tuples.foreach(((String letter, String number)) =>
    println("letter: "+letter+" number: "+number)
  );
  */
}
-- AlexGreif? - 05 Mar 2003

I agree it would be practical to be able to name the components of the tuple in its type declaration. This is actually already possible for a local declaration, which you use in the first function. But it needs to be implemented for function declarations.

We also have to disambiguate with the first case, by putting additional brackets:

((String letter, String number)) => ...

-- DanielBonniot?

This feature is now implemented (in the CVS-tree and will be in the 0.9.0 release) -- ArjanB - 16 Jun 2003

Topic TupleFunctionDeclaration . { Edit | Attach | Ref-By | Printable | Diffs | r1.3 | > | r1.2 | > | r1.1 | More }
Revision r1.3 - 18 Jun 2003 - 18:07 GMT - DanielBonniot
Parents: WebHome > FeatureProposals
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback.