Forum: Ruby Re: A more elegant way to do this?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
397f61cc4458e13157b4facf72325e5f?d=identicon&s=25 Gennady Bystritsky (Guest)
on 2006-05-11 08:19
(Received via mailing list)
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 topic is locked and can not be replied to.