From: Ammar Ali Date: 2012-04-11T13:09:44+09:00 Subject: Re: less absolutely horrible way to make sure array 1 only contains elements from array 2? On Wed, Apr 11, 2012 at 4:44 AM, ruby ismyname wrote: > I need to make sure that myselections only contains elements from > choices, includes? doesn't work because it allows for partial matches. > This works but it looks absolutely horrible. How about using array difference using the #- method? >> choices = [1, 2, 3, 4] => [1, 2, 3, 4] >> selection_good = [2, 4] => [2, 4] >> selection_good - choices => [] >> selection_bad = [2, 6] => [2, 6] >> selection_bad - choices => [6] HTH, Ammar