Programming in D page 217 - unittests for custom exceptions

Erdem zayifakimkolu at gmail.com
Wed Jan 21 14:44:05 UTC 2026


On Wednesday, 21 January 2026 at 00:08:32 UTC, Brother Bill wrote:
> Is the mistake on my side or D's side?

The function's detail should be written by you.

> void average(int[] a, int[] b)
> {
> 	throw new UnequalLengths("Unequal lengths");
> }

How can you determine the size of arrays passed to the function 
are not the same?

```d
int[] average(int[] a, int[] b)
{
     // ...
     int[] average;
     if (a.length != b.length)
         throw new UnequalLengths("Unequal lengths");
     return average;
}
```


More information about the Digitalmars-d-learn mailing list