Hi, today I read the documentation about Tuple. I saw there is a function .from(array : Array). But I can’t use it to have the result I expected.
Somebody can explain me how to convert an array to a Tuple ?
I mean convert, or get a Tuple with the array content
Can you share the error/unexpected result you’re getting? The catch with this method is that you have to know the amount items and their types. E.g. you can just do
Tuple.from([1, 2, 3]) you’d have to do
Tuple(Int32, Int32, Int32).from([1, 2, 3]), which would error if there are more or less than 3 arguments, or the types do not match those in the type vars.
This is my main problem, I need to pass the type of each element.
Just to explain you, I need to make a Tuple from an Array of ISM::SoftwareInformation, but I don’t know the size of this array at the beginning, it’s only after my software check all recorded SoftwareInformation on the database.
How can I pass the type multiplicated by the number of elements in my array ?
I don’t think you can if the amount of items is only known at runtime. Tuples are a compile time construct, you can’t just dynamically create them. Might be best to take a step back and try a different approach.
Oh okay I wasn’t sure. I just try to found way to improve speed time.
It can be a good idea for example to generate a json file of this array, and after load it as a Tuple ?
If the data is truly dynamic, then an array is probably the correct data type.
Yeah make sense now. Thanks !