On Tue, 29 Jun 2010 15:27:41 -0400, bearophile wrote:

> In D use dynamic arrays unless you really need to remove or add a lot of
> items from the start or middle of the sequence. On modern CPUs linked
> lists are usually the wrong data structure to use.
> 
> Bye,
> bearophile

D's dynamic arrays are great!  Also you should create a constructor for a 
common build operation.

--------------------------------------------
import std.stdio;

class Server
{
        string name;
        string ip;

        this( string _name, string _ip ) { name = _name; ip = _ip; }

        string toString() { return name ~ " - " ~ ip; }
}


void main()
{
        Server[] serverList = [ new Server( "a", "164.76.0.1" ), 
                                new Server( "b", "164.76.0.2" ) ];
        foreach( server; serverList ) {
                writeln( server );
        }
}
-----------------------------------------

a - 164.76.0.1
b - 164.76.0.2

-B

Reply via email to