Is there a good way to convert a list of items with no more than 1 item in it to a single item? There are 2 ways I know of, both have minor issues depending on the context.
1) use an index such as array[1] to get the first value of the array - This works, but requires some null checking in case the array is empty as it will bug out if that is the case.
2) use cast, but this requires knowing the type ahead of time, and if that's not possible, neither is this casting method.
Is there any other way I'm missing? Some hidden fromList() function I haven't found yet?
Discussion posts and replies are publicly visible
index(ri!list, 1, null())
Index is returning another array. Why is that?
It can happen if you are passing multiple indexes i.e. index({10, 20, 30}, {1, 3}, null) returns {10,30}. What is your use case please share some more info for better understanding.