struct, ref in, and UFCS

Puming via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 30 22:09:47 PDT 2014


Hi,

I have a struct and want to extends its methods, like:

```d
struct Server
{
   string name;
   string ip;
   int port;
   string user;
}
```

extension method here:

```d
string prompt(ref in Server server)
{
    return server.user ~ "@" ~ server.ip ~ ":" ~ server.port;
}

```

and call it with UFSC:

```d
string p = server.prompt;
```

is this the correct way to use struct and UFCS? it does not seem 
to copy there.


More information about the Digitalmars-d-learn mailing list