Question : ruby array remove by index
Answered by : wideeyed-willet-pq2xtqf9umid
a= [1,1,1,2,2,3]
delete_list = [1,3]
delete_list.each do |del| a.delete_at(a.index(del))
end
Source : https://stackoverflow.com/questions/8929053/removing-elements-from-array-ruby | Last Update : Wed, 27 Jan 21
Question : ruby remove nil element in array
Answered by : unsightly-unicorn-041hcpxy3hwb
[nil, 'apple', 'orange', '', 'banana'].compact
=> ["apple", "orange", "", "banana"]
Source : http://rubysnippets.net/documents/ruby-cheatsheet-for-array | Last Update : Mon, 16 May 22