Closed HorridModz closed 1 year ago
I don't think this is wrong. It is explained in chapter 8. Because this method implements the interface method E visitBlockStmt
and E is of type Void it needs to return null.
class Interpreter implements Expr.Visitor<Object>,
Stmt.Visitor<Void> {
The reason this can't be Stmt.Visitor<void>
is explained in the note:
Java doesn’t let you use lowercase “void” as a generic type argument for obscure reasons having to do with type erasure and the stack. Instead, there is a separate “Void” type specifically for this use. Sort of a “boxed void”, like “Integer” is for “int”.
So because of the <Void>
the return type needs to be Void
and the method must have return null;
Sorry for the misunderstanding! Thanks for correcting me.
Respect!!!!!On 15 Apr 2023, at 3:43 am, HorridModz @.***> wrote: Sorry for the misunderstanding! Thanks for correcting me.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
@petejerky ?
YesOn 17 Apr 2023, at 1:18 pm, HorridModz @.***> wrote: @petejerky ?
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.***>
In 11.3.1 (page 178 in physical book), there is this code:
I believe there's two things wrong with this code.