D
David N. Welton
Hi,
foo = { 'a' => 1, 'b' => '', 'c' => 23213 }
bar = Hash[*foo.find_all { |k, v| !v.to_s.empty? }.flatten]
1) The flatten isn't quite what I want, although it will work in my case.
2) Is there an even better way to be doing this? It's starting to be a
lot of stuff in one line, so perhaps it's best to just do it in a few
lines and opt for clarity. But I'm completely new to Ruby, so I'd also
like advice on 'style'...
Thanks!
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/
foo = { 'a' => 1, 'b' => '', 'c' => 23213 }
bar = Hash[*foo.find_all { |k, v| !v.to_s.empty? }.flatten]
1) The flatten isn't quite what I want, although it will work in my case.
2) Is there an even better way to be doing this? It's starting to be a
lot of stuff in one line, so perhaps it's best to just do it in a few
lines and opt for clarity. But I'm completely new to Ruby, so I'd also
like advice on 'style'...
Thanks!
--
David N. Welton
- http://www.dedasys.com/davidw/
Linux, Open Source Consulting
- http://www.dedasys.com/