Ubound confusion in supplied PDF manual

Just learning Xojo via its downloaded PDF manual. Correct me if I’m in error, but this looks wrong on page 122:

Dim stooges() As String
// Ubound(stooges) is now equal to -1
// Ubound(stooges) is now equal to 3

Shouldn’t that last Ubound value be 2?

You are correct. It should be 2.

Thanks. I was confused because the author says Ubound gives me the total of elements in an array:

Many times, you will not know how many items are in an array. You can
ask Xojo how many items are in an array by using the Ubound function
(Ubound is short for “upper bound”):

myArrayCount = Ubound(myStringList)

Obviously the total would be Ubound(myStringList) + 1. That said, I still find this text to be quite nicely done.

Yes… all of your observations are correct.

Ubound does give the upper bound… but as you noticed… since Arrays are 0 based… Ubound+1 is the actual # of items

HOWEVER… do note there are a few instances where things are 1-based. Folderitem properties are a prime example.

Thanks for catching this. I’ve forwarded this to Brad Rhine (bradrhine@gmail.com), the author of the Intro to Programming book, to get this updated for the next version.