Re: A more elegant way to do this?

Array() will do the job:

Array(nil) => []
Array([1,2,3]) => [1, 2, 3]
Array(1) => [1]

In your case:

Array(conf[‘hosts’][hostname][‘groups’]).each { … }

Gennady.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs