Have you ever been in a situation where you needed a method that does all of the following?
nil to an empty Array, andn to [n], andThe way to achieve this, is using the little known method Array():
Array(nil) # => [] Array([]) # => [] Array(1) # => [1] Array([2]) # => [2]
(Source: rubyloveinfo)
5 notes 0 comments (via rubyloveinfo)
following? Convert...Array, and convert a non-Array...[n],...
You can use HTML tags for formatting. Wrap code in <code> tags and multiple lines of code in <pre><code> tags.