Consider calling function foobar with arguments,
list[int] exampleA=[1,2,3];
list[int] exampleB=[];
//call with under-sized list
foobar(exampleA); //everything ok, exception caught and handled
//call with empty list
foobar(exampleB); //throws an exception: emptyList
public void foobar(list[int] intList)
{
try
{
int i=0;
while(i<=5)
{
println(intList[i]);
i++;
}
}
catch IndexOutOfBounds(msg):
{
//do something
}
}
Shouldn't IndexOutOfBounds technically be same as emptyList? What maybe the reason that these situations are considered two different exception conditions?