Helper function to avoid unnecessary copying if x is already an array.
remarks
First checks if x is an array and if so returns it. Else attempts to obtain an iterator from x and if successful collects it as array and returns it. Throws error if x isn't iterable.
Helper function to avoid unnecessary copying if
x
is already an array.First checks if
x
is an array and if so returns it. Else attempts to obtain an iterator fromx
and if successful collects it as array and returns it. Throws error ifx
isn't iterable.