D newb

Tim H thockin+d at hockin.org
Sun Aug 17 19:35:47 PDT 2008


bearophile Wrote:


> >         public int m_int = 0;
> This is enough:
>         public int m_int;
> Because variables are initialized to .init by default (and there's a way to avoid that), and int.init is 0.

So every variable is 0 initialized?

> > int main(string[] args)
> 
> You can use this, because the return value is automatic:
> void main()

If I want to return a value other than 0, how do I do it?

> To print writef/writefln is generally better, because typesafe (but it makes your executable fatter):
> writefln(foo %d", f.m_int);

What does that mean - to be typesafe?  Can you give me a real example of where writef() is better than printf().

I'm looking for a good D tutorial.  Something that would have all these answers.  Can you recommend one?  I've been writing C for a dozen years and C++ for a few, as well as other stuff here and there.

Tim



More information about the Digitalmars-d mailing list