array.compact.reject { |i| i.nil? or i.empty? } seemed to leave some
unwanted elements, at least on my Ruby 1.8.6.

But array.delete_if { |i| i.nil? or i.empty? } worked as expected on
my machine.

HTH,
Richard


array.delete_if { |i| i.nil? or i.empty? }

On Mar 1, 2:19 pm, Kirk Patrick <[email protected]> wrote:
> [email protected] wrote:
> > Also does not behave with this code:
>
> > s = "onexytwoxyxythreexyxyxyfour"
> > p s.split(/(xy)+/)
>
> Try this:
>
> s = "one<br>two<br><br>three<br><br><br>four"
> array = s.split('<br>')
> array.compact.reject { |i| i.nil? or i.empty? }
>
> This will produce:
>
> ['one', 'two', 'three', 'four' ]
>
> Regards,
>
> Atc.,
> Kirk Patrick
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to