Thursday, July 16, 2009

Why Does ArrayAppend Return True and ListAppend Returns the List

Nothing major, but if you are the curious type there was an interesting question today on stackoverflow. It is one of those simple things that you probably use every day, but may not stop to wonder "why is it this way?".

Why does arrayAppend return true and listAppend return the list?

I suspect the mutability issue is probably the biggest reason. But I seem to recall another suggestion (maybe on I believe the poster suggested it might be linked to the fact that arrays are java.util.Vector's. So it is very likely arrays use the Vector.add(Object) method. According to the api the add() method should return a boolean value:

But that does raise another question. Are there any circumstances under which ArrayAppend(..) would actually return false?


  © Blogger templates The Professional Template by 2008

Header image adapted from atomicjeep