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
yes, the curly brackets will cause anything you put in them to be typed as an array. the index() function can also return array types either (as noted) if the indices passed into it are an array, or if the index being returned is also an array - which is why I noted it all depends on the original data and manner of use.