Michael Grosser, the Blog

Google+ LinkedIn Twitter

Menu

Skip to content
  • Home
  • About

Ruby helper of the day: Array.compact

I just found this handy helper:

list.reject(&:nil?) == list.compact

It removes any nil elements from a given array see: docs

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • More
  • Click to email a link to a friend (Opens in new window) Email
  • Click to share on Flattr (Opens in new window) Flattr
  • Click to print (Opens in new window) Print
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on Tumblr (Opens in new window) Tumblr
Like Loading...

Related

2009-04-08pragmatig Ruby

Post navigation

← My Netbeans Shortcuts
recursive symbolize_keys →

Leave a comment Cancel reply

  • Event delegation with almost any Selector
  • ActiveRecord.find_each_with_order = find_each with order...
  • How to name RSpec describe blocks for methods
  • Makefile: speedup go build & run by using mtimes

Recent Posts

  • Testing Kubernetes CEL admission/valdiation
  • Producing Golang error backtraces / stacktraces
  • Makefile: speedup go build & run by using mtimes
  • Datadog: Show Metric Usage Warning From HPA Metrics
  • Kubernetes Changelog from Audit log
Create a website or blog at WordPress.com
  • Comment
  • Reblog
  • Subscribe Subscribed
    • Michael Grosser, the Blog
    • Already have a WordPress.com account? Log in now.
    • Michael Grosser, the Blog
    • Subscribe Subscribed
    • Sign up
    • Log in
    • Copy shortlink
    • Report this content
    • View post in Reader
    • Manage subscriptions
    • Collapse this bar
%d