I have a loop inside which I am appending the result of the loop to an array. The code is like this
urls = []
series_id = [100,200,300,400]
series_id.each do |id|
result_urls += iterate_id_and_get_urls(id)
end
def iterate_id_and_get_urls(id)
#do something with id and maps it and returns its url which would result in an array
#return that url array
end
But iterate_id_and_get_urls(id) can also return nil sometimes which would result nil to be appended in result_urls. How can I avoid that. I am looking for something like the below
result_urls += iterate_id_and_get_urls(id) unless nil?