07-19-2023, 01:39 AM
You can use **delete_if**:
['', 'hola'].delete_if(&:empty?)
If you're using Rails, you can replace **empty?** by **blank?**
['', 'hola'].delete_if(&:blank?)
or use a block:
['', 'hola'].delete_if{ |x| x == '' }
['', 'hola'].delete_if(&:empty?)
If you're using Rails, you can replace **empty?** by **blank?**
['', 'hola'].delete_if(&:blank?)
or use a block:
['', 'hola'].delete_if{ |x| x == '' }