[2.0-beta.9] ArrayObject.InsertAt() bug (or doc error perhaps) Topic is solved

Report problems with documented functionality
burque505
Posts: 1736
Joined: 22 Jan 2017, 19:37

[2.0-beta.9] ArrayObject.InsertAt() bug (or doc error perhaps)

10 Sep 2022, 13:08

Issue: Empty Array elements throw error if left entirely blank (e.g. 'x.InsertAt(1, , "B")').

Test code (Code copied from Array.InsertAt example:

Code: Select all

x := ["C"]
x.InsertAt(1,  , "B")    ; =>  [   , "B", "C"]
MsgBox(" First element is " x[1] " and second element is " x[2])
Error:
Array_InsertAt.PNG
Array_InsertAt.PNG (5.49 KiB) Viewed 673 times
Workaround:
After reviewing this page (first and second Lexikos posts on that page) I tried this:

Code: Select all

x := ["C"]
x.InsertAt(1, ""  , "B")    ; =>  [   , "B", "C"]

MsgBox(" First element is " x[1] " and second element is " x[2], "Workaround")
Result:
insert_at_w0.PNG
insert_at_w0.PNG (3.76 KiB) Viewed 673 times
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: [2.0-beta.9] ArrayObject.InsertAt() bug (or doc error perhaps)

10 Sep 2022, 18:40

It is completely unrelated to the v2.0-beta.8 changes; those only affected a selection of built-in functions, not any objects. For those functions, generally "" was previously the same as omitting the parameter. Omitting an array element is not the same as passing "".

Despite that example, the usage of InsertAt is documented as follows:
ArrayObj.InsertAt(Index, Value1 [, Value2, ... ValueN])
Evidently Value1 is a required parameter. You cannot omit it.

This will be changed.

Note: Only the first value is required.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 13 guests