That doesn't work with other objects, you can't get an integer from a function that returns a non standard Object (TList, TMap, TMyType etc..)
EDIT: Using what you posted would not allow different return values.
EDIT: Using what you posted would not allow different return values.