Convert List to single value

Certified Senior Developer

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

Top Replies

Parents Reply Children
No Data