On 05/30/12 20:34, nrgyzer wrote:
> Hi,
>
> I've the following enumeration:
>
> enum path : string {
>
> log1 = "/var/log1",
> log2 = "/var/log2"
>
> }
>
> Now... when I try to do the following:
>
> string subDirectory = "example";
>
> string newPath = buildPath(path.log1, subDirectory);
A better solution is to use:
struct Path {
enum : string {
log1 = "/var/log1",
log2 = "/var/log2"
}
}
Or even just:
struct Path {
enum string log1 = "/var/log1",
log2 = "/var/log2";
}
(In D structs, classes and enums start with an upper case).
Bye,
== Auszug aus bearophile (bearophileh...@lycos.com)'s Artikel
> nrgyzer:
> > Is this a bug in std.path.buildPath() or is there anything I'm
> > doing wrong?
> The signature of buildPath is:
> immutable(C)[] buildPath(C)(const(C[])[] paths...);
> But your inputs aren't of the same type. Named enum c
nrgyzer:
Is this a bug in std.path.buildPath() or is there anything I'm
doing wrong?
The signature of buildPath is:
immutable(C)[] buildPath(C)(const(C[])[] paths...);
But your inputs aren't of the same type. Named enum create their
own type. You give buildPath a type string and a type path
Hi,
I've the following enumeration:
enum path : string {
log1 = "/var/log1",
log2 = "/var/log2"
}
Now... when I try to do the following:
string subDirectory = "example";
string newPath = buildPath(path.log1, subDirectory);
I get the following errors:
Error: template std.path.buildPath