I have two array functions:
def available_billing_address_types
options = []
options << "Home" if address.present?
options << "Organisation" if organisation.present?
return options
end
def available_billing_address_types
options = ["Home", "Organisation"]
options.delete_at(0) if address.blank?
options.delete_at(1) if organisation.blank?
return options
end
The first one works as expected, the seconds one doesn’t.
I suspect that it’s not possible to tun delete_at() twice?
Or what am I missing here?
Thanks for any help…
You have this array:
If you now call
options.delete_at(0)you have this array:So if you now call
options.delete_at(1)there is no element1to delete.You could do this: