On Thursday, 13 December 2012 at 04:11:10 UTC, Pacoup wrote:
I've been newly exploring D for a very short while now, and, exploring Array functionality, I came upon this funny bit of code off of a badly written tutorial.

import std.stdio;

void main()
{
   int[] intArray;
        
   intArray[0] = 42;
   intArray[1] = 54;
   intArray[2] = 91;

   writefln("The length of intArray is %d.", intArray.length);
}

This compiles, believe it or not, and doesn't throw any errors or warnings whatsoever, but obviously for people who know D, this will throw a core.exception.RangeError: Range violation when run.

Why?

It's C++ philosophy imposed on the C#-like aspects of the language.

Reply via email to