Skip to content

Instantly share code, notes, and snippets.

Created February 19, 2016 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1d1b6d4ac0b09b8429e4 to your computer and use it in GitHub Desktop.
Save anonymous/1d1b6d4ac0b09b8429e4 to your computer and use it in GitHub Desktop.
public class TupleTest {
static class Tuple3<T1, T2, T3> {
T1 v1;
T2 v2;
T3 v3;
public Tuple3(T1 v1, T2 v2, T3 v3) {
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
}
}
static <T> void forEach(Tuple3<? extends T, ? extends T, ? extends T> tuple, Consumer<? super T> consumer) {
consumer.accept(tuple.v1);
consumer.accept(tuple.v2);
consumer.accept(tuple.v3);
}
public static void main(String[] args) {
Tuple3<Integer, Long, Byte> t = new Tuple3<>(42, 0L, (byte) 1);
forEach(t, e -> System.out.println(e.doubleValue()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment