What are these functions called and how to implement they?

dog2002 742617000027 at aaathats3as.com
Fri Jan 29 06:54:22 UTC 2021


On Thursday, 28 January 2021 at 18:56:15 UTC, frame wrote:
> On Thursday, 28 January 2021 at 18:27:09 UTC, frame wrote:
>
>> [...]
>
> A very simple example:
>
> bool myEventA = true;
> bool myEventB = false;
>
> // event source that generates the event (must be called to run)
> void source() {
>     observe(myEventA);
> }
>
> // routine that decides what handler to call
> void observe(bool event) {
>     switch (event) {
>     case true:
>         onMyEventA(event);
>         break;
>
>     case false:
>         onMyEventB(event);
>         break;
>
>     default:
>         assert(0);
>     }
> }
>
> // handler
> void onMyEventA(bool event) {
>     // do something
> }
>
> void onMyEventB(bool event) {
>     // do something
> }

Thank you, I'll try it


More information about the Digitalmars-d-learn mailing list