Hi all,

Is there any build-in method of class Array which can be used to find
the first non-nil element in an array? I can't find any so I am trying
to achieve it by my own approach. I don't think my approach is smart
enough, so I would like to know better one to do so. Here is what I am
doing:

a = [nil, "hello", "world"]
b = a
b.compact!
first_non_nil_elem =  b.first

I don't call "compact!" directly on a because it will change a's
structure, I want to reserve nil elements in a.

Any suggestions are really appreciated!