# Re: A more elegant way to do this?

**URL:** <https://www.ruby-forum.com/t/re-a-more-elegant-way-to-do-this/94693>\
**Category:** Ruby\
**Created:** [May 11, 2006, 8:19am UTC](https://www.ruby-forum.com/t/re-a-more-elegant-way-to-do-this/94693 "2006-05-11T08:19:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [May 11, 2006, 8:19am UTC](https://www.ruby-forum.com/t/re-a-more-elegant-way-to-do-this/94693/1 "2006-05-11T08:19:33Z")

</div>

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.
