Working with modules

Colin Grogan grogan.colin at gmail.com
Fri Feb 15 04:03:21 PST 2013


Ok, I had a minute so I tested it out.

I had the following:

> src/main.d:
>    import utils._;
>
>    void main(string[] args){
>        logger l = new logger();
>        props p = new props();
>        l.print();
>        p.print();
>    }
>
> src/utils/_.d
>    module utils._;
>    public import utils.props, utils.logger;
>
> src/utils/logger.d
>    module utils.logger;
>    import std.stdio;
>
>    public class logger{
>        this(){}
>        public void print(){
>                writefln("This is logger...");
>        }
>    }
>
> src/utils/props.d
>    module utils.props;
>
>    import std.stdio;
>
>    public class props{
>        this(){}
>        public void print(){
>                writefln("This is props...");
>        }
>    }


Compiled and ran it, and it printed out
     This is logger...
    This is props...
as I expected.

That's perfect, solves my problem quite well I think!

Thanks all!


More information about the Digitalmars-d-learn mailing list