Why can't I explicitly return void from a method?

前端 未结 14 2204
萌比男神i
萌比男神i 2021-01-01 08:23
void run() {
    ...
    if (done) return cancel();
    ...
}

where cancel() return void. This won\'t compile... and I ca

14条回答
  •  被撕碎了的回忆
    2021-01-01 08:58

    It's a tautology. Meaning, void defines that the method has no return value. Therefore, how can you "return void" when void is no return at all?

提交回复
热议问题