Skip to content

Instantly share code, notes, and snippets.

@twh270
twh270 / GenericsTrouble.java
Last active May 15, 2020 23:53
Trouble with generics
import java.util.function.*;
/*
Problem solved -- thanks to https://www.reddit.com/user/Yggval for identifying the trouble
(see https://www.reddit.com/r/javahelp/comments/gkid8w/trouble_with_generics/)
Working solution follows: essentially, Sequence<T> needs to be Sequence<T, U> so the
Compose<IdentifierNode, IdentifierNode, TypeExpressionNode> which extends NodeParseRule<IdentifierNode, TypeExpressionNode>
can map to the first argument of the Sequence constructor.
*/
import java.util.Scanner;
public class CardFlip {
static boolean DEBUG = false;
private enum CardValue {
A, B, C, D;
}
private static class Card {