Kaustubh Dixit
Kaustubh Dixit

Reputation: 178

runtimeType of Lexical Closure

Code:

void main(){
  print(foo().runtimeType);
}

Function foo(){
  return (){};
}

Output:

() => Null

Why is this Null and not void?

Upvotes: 0

Views: 60

Answers (1)

Eimantas G
Eimantas G

Reputation: 467

From dart official site:

All functions return a value. If no return value is specified, the statement return null; is implicitly appended to the function body.

Upvotes: 2

Related Questions