{"id":36362,"date":"2008-04-02T18:26:00","date_gmt":"2008-04-02T18:26:00","guid":{"rendered":"\/2008\/04\/02\/ruby-include-versus-intersection"},"modified":"2009-08-30T04:45:35","modified_gmt":"2009-08-30T04:45:35","slug":"ruby-include-versus-intersection","status":"publish","type":"post","link":"http:\/\/pullmonkey.com\/2008\/04\/02\/ruby-include-versus-intersection\/","title":{"rendered":"Ruby – include? versus intersection"},"content":{"rendered":"
After my last article about intersection and arrays<\/a>, I got to thinking how this could apply elsewhere.
\nI decided to see if I could write a faster include?() method for Array using the intersection operator. So here is what I did:<\/p>\n1) Tested via irb (of course)<\/h3>\n
\n1\n<\/tt>2\n<\/tt>3\n<\/tt>4\n<\/tt>5<\/strong>\n<\/tt>6\n<\/tt>7\n<\/tt>8\n<\/tt>9\n<\/tt>10<\/strong>\n<\/tt>11\n<\/tt>12\n<\/tt>13\n<\/tt>14\n<\/tt>15<\/strong>\n<\/tt>16\n<\/tt>17\n<\/tt>18\n<\/tt>19\n<\/tt>20<\/strong>\n<\/tt><\/pre>\n<\/td>\n |