> > |
%META:TOPICINFO{author="guest" date="1046861160" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="FeatureProposals"}%
This page describes the feature request to use tupel types in function declaration of anonymos 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? |