Convert array of string elements to integer elements
Say I have an array of string elements ["1", "2","3"] that I wish to sum. However, I cannot just use the formula .sum because it would combine the string elements to return "123" instead of 6.
How can I convert the array to integer elements for summation?
Amanda Wong
said
over 2 years ago
Hi Saul, we do not have a formula to convert the string elements into integer elements. However, this can be done using a simple ruby code laid out in this recipe. The code takes care of the conversion into integers as well as the summation.
Saul Macht
Convert array of string elements to integer elements
Say I have an array of string elements ["1", "2","3"] that I wish to sum. However, I cannot just use the formula .sum because it would combine the string elements to return "123" instead of 6.
How can I convert the array to integer elements for summation?