In Javascript, you can define an anonymous function that can be executed immediately. It is called an Immediate Invocation Function Expression, aka IIFE.
First, you declare the function, like so:
function
() {
console.log(
'Immediately invoked function execution'
);
}
Then, you wrap it up in ():
(
})
Finally, you add another () to execute it:
})()
In Delphi, similarly, you can define an anonymous method:
procedure
begin
WriteLn
'Hello world'
end
Then, you wrap it up with ():
)
And finally, execute it!
)();
Here's another example:
((
const
X:
string
):
Boolean
(X);
Result :=
True
;
)(
'Hello'
));
The output for this shows the following x:
HelloTRUE