Re: A more elegant way to do this?


#1

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.