Hi All,

Request your help, I have a struct which has many functions, I need to run a function from within another function(From Display function execute the runner function), an example as below

```
import std.stdio: writeln;
import std.algorithm: joiner;
import std.parallelism: task;
import std.typecons: tuple;

struct MainEngine {
    int rno;
    string firstname;
    string lastname;
    int age;

    this(in int _rno) { rno = _rno; }
auto ref FirstName(in string _firstname) { firstname = _firstname; return this; } auto ref lastName(in string _lastname) { firstname = _lastname; return this; }
    auto ref Age(in int _age) { age = _age; return this; }
    auto Display () {

        auto runner(string status = "Male") {
auto record = tuple([firstname,",",lastname].joiner, age, status);
                        return record;
        }
        string *runnerptr = &runner;

        auto result = task(*runnerptr);
        result.executeInNewThread;
        result.yieldForce;
        return result;
    }
}

void main () {
auto mrunner = MainEngine(1).FirstName("Fname").lastName("Lname").Age(25).Display();
        writeln(mrunner);
}
```

From,
Vino

Reply via email to