Yeah, I believe you would. I think myClasses should probably be a Set instead of a List. It looks like the signup method already anticipates that you might already be signed up for a class, though the surrounding code doesn’t
Another scenario that I just encountered while debugging an error in the Tokio Class Scheduling App.
In the following code, suppose both oldC and newC contain classes that the student has already signed up for. Basically the student is trying to switch between two classes she has already signed up for.
private static void switchClasses(TransactionContext db, final String s, final String oldC, final String newC) {
db.run((Transaction tr) -> {
drop(tr, s, oldC);
signup(tr, s, newC);
return null;
});
}
In this scenario, there is nothing to switch. However, from what I am understanding, we would be dropping oldC, and ignoring the second signup of newC.