Compact Array

Remove falsy values (null, false, 0, empty strings) from an array.

Code

General
arr.reject { |x| !x || x == 0 || x == '' }

Parameters

Array with falsy values

Server

More Ruby Snippets