There is nothing in Delphi like a Python callable object. Or a C++ function call operator().
Is it possible in Delphi to have a callable object like I can do in Python using the __call__() method?
Pergunta
As the question says, using Python I am able to do something like this:
class myCallableClass(object):
def __call__(self, value):
return 'myCallableClass: ' + value
my_instance = myCallableClass()
# I am calling the istance of my class like a function
my_var = my_instance('string')
print(my_var) # prints 'myCallableClass: string'
Is there a way to achieve something similar in Delphi?
Solução
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow