Catching array out of bounds

jicman cabrera_ at _wrc.xerox.com
Wed Nov 4 21:26:33 PST 2009


Greetings!

I have this program,

import std.stdio;
void main()
{
  char[][] a = ["a","b","c"];
  try
  {
    writefln(a[3]);
  }
  catch (ArrayBoundsError)
  {
    writefln("error...");
  }
}

when I compile it, I get,

23:53:52.73>build -I..;c:\D\dmd\import array.d
array.d(10): Error: identifier 'ArrayBoundsError' is not defined
array.d(10): Error: ArrayBoundsError is used as a type
Error: can only catch class objects, not 'void'

This is right from the D1 Arrays help...

http://www.digitalmars.com/d/1.0/arrays.html

What am I doing wrong?

thanks,

josé




More information about the Digitalmars-d-learn mailing list