RubyFlow The Ruby and Rails community linklog

×

The Ruby and Rails community linklog

Made a library? Written a blog post? Found a useful tutorial? Share it with the Ruby community here or just enjoy what everyone else has found!

Convert Ruby object to array

Have you ever been in a situation where you needed a method that does the following:

  • Converts nil to an empty array
  • Converts non-array variable n to [n]
  • Leaves array variable as is

It can be accomplished using this method.

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in