['a', nil, '', 'b'].compact.reject(&:empty?)
=> ["a", "b"]
['a', nil, '', 'b'].compact.delete_if(&:empty?)
=> ["a", "b"]
なにかで便利メソッドが提供されてる気もする...
ActiveSupportにString#blank?があった。
['a', nil, '', 'b'].reject(&:blank?)
=> ["a", "b"]
Go to list of users who liked
More than 5 years have passed since last update.
['a', nil, '', 'b'].compact.reject(&:empty?)
=> ["a", "b"]
['a', nil, '', 'b'].compact.delete_if(&:empty?)
=> ["a", "b"]
なにかで便利メソッドが提供されてる気もする...
ActiveSupportにString#blank?があった。
['a', nil, '', 'b'].reject(&:blank?)
=> ["a", "b"]
Register as a new user and use Qiita more conveniently
Go to list of users who liked