Show the array index numbers when using print() in Expressive Output Window

The ability to print a table in the Expressive Output Window is fantastic and it just keeps getting better.
But I often miss seeing the index number in arrays (position in the array), in addition to the value, currently shown.
It would be very important to show the index number as well, as it serves as a reference for debugging, as for table.remove, etc.
Also, the indexed array is not being shown in numerical order, like ipairs:

Repro

  1. Activate Expressive Output Window beta
  2. Run this script:
local arr = {}
for i = 1, 10, 1 do
	table.insert(arr, "value" .. i*5-1)
end
print("Expressive Window:")
print(arr)

print("For Ipairs:")
for i, v in ipairs(arr) do
	print(i, v)
end
  1. It will show the results like:

The last one should be the correct way to print arrays in Expressive Output Window.

2 Likes

Hey rogeriodec_games,

Thanks for your suggestion, we will look into this. Also please keep in mind that this is not a bug but a feature request. For suggestions like this, please use the Studio Features category instead of Studio Bugs, thanks.

The array being shown in a non numerical order is not a bug?

Lua tables are sets of key-value pairs. There is no order.

The Lua manual says:

The order in which the indices are enumerated is not specified, even for numeric indices.

Was there a time when the Output Widget printed the array in numerical order and now you are seeing the non numerical order? If yes, then I misunderstood and this is a bug. If not, then this is a feature request as Output never had this behavior to begin with. Nonetheless we understand the advantage of printing in numerical order and will look into incorporating it into the Expressive Output Widget.

Ok, so there are two issues in the OP.

  1. Show index number for arrays: Feature Request
  2. Indexed array is not being shown in numerical order: bug

I’ve moved this to Studio features. If you want to report the other one as a bug, please use a separate thread and follow the requirements for posting a bug report.

2 Likes

Np, I created a bug report there: Array is not being shown in numerical order using print() with Expressive Output Window beta

Tks

1 Like

I noticed this feature was included in the 452 version, as I described here.
Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.