Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert a function to delegate

I have a property that accepts a delegate: http.onReceiveHeader = (in char\[\] key, in char\[\] value) { }. I want to use a separed function instead of, e.g:

void do_something(char[] key, char[] value)
{
}

http.onReceiveHeader = do_something;

it's possible do it in D?

like image 222
Jack Avatar asked Jan 21 '26 07:01

Jack


1 Answers

There is a toDelegate function in std.functional.

So this should work:

http.onReceiveHeader = toDelegate(do_something);
like image 104
dav1d Avatar answered Jan 23 '26 20:01

dav1d



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!