I have two arrays generated from :
@dividends_values = @dividends.historical.map(&:dividend).reverse.last(50)
@dividends_dates = @dividends.historical.map(&:date).reverse.last(50)
The first array is an array of float values and occasional there can be a few nil entries in that. I want to remove those nil entries(which is pretty easy with a compact or something like that), but I also want to move the corresponding entries from the @dividends_dates array.
That is because they the dates array is a 1-1 reference to the values array, so index 0 of array with dates correspondings to index 0 of array with values.
What is a good way to do that?
@dividends_values[3]is nil then also remove@dividends_dates[3]?[dividend, date]pairs and remove all entries with adividend(first value) ofnil. Afterwards separate the pairs.