From: Lars Haugseth Date: 2012-04-11T20:25:04+09:00 Subject: Re: less absolutely horrible way to make sure array 1 only contains elements from array 2? On 04/11/2012 01:16 PM, Lars Haugseth wrote: > > require 'set' > > valid_choices = Set[:a, :b, :c, :d, :e, :f] > > good = Set[:a, :b, :d, :e] > good.subset? choices > => true > > bad = Set[:c, :f, :x, :y] > bad.subset? choices > => false > > Note: you can use Array#to_set to convert an array to a set. > Should be: good.subset? valid_choices bad.subset? valid_choices -- Lars Haugseth