+ 2

Why this code ends and print 4? Instead of a StackOverFlow Exception

https://code.sololearn.com/c1zySK1iKmts/?ref=app

23rd Aug 2019, 9:42 PM
Joel David Hernández Cruz
Joel David Hernández Cruz - avatar
3 Respuestas
+ 2
The Func object is passed as a parameter of the Four function, but in the body of the Four function it is never executed in the Func object passed as a parameter. The only thing that is done in the body of the Four function is to return 4.
23rd Aug 2019, 10:28 PM
Leynier Gutiérrez González
Leynier Gutiérrez González - avatar
+ 1
It must be beacuse the function infinity is never actually excecuted, but I don't quite understand why.
23rd Aug 2019, 9:53 PM
Joel David Hernández Cruz
Joel David Hernández Cruz - avatar
+ 1
Yeah that's what I thought, since you pass infinity that's just the func declaration, you don't actually invoke that function inside the Four function body
24th Aug 2019, 9:30 PM
Joel David Hernández Cruz
Joel David Hernández Cruz - avatar