From: Bill Walton Date: 2008-07-20T22:17:59+09:00 Subject: Re: The next number that is not in an array Hi David, David A. Black wrote: > So like this? > > irb(main):020:0> a = [2,3,4,8,12,13,15] > => [2, 3, 4, 8, 12, 13, 15] > irb(main):021:0> ([*a[0]..20] - a).shift > => 5 > > It's a cool idea, Thanks. > though I would find it somewhat hard to see what's > going on at a glance than some of the others. Yeah. I wasn't sure of the overall context. If the reserved numbers list was static and there was a need to call the get_next method more than once, I thought getting and saving the array difference (as a separate step before the shift) could pay dividends later that might make it a reasonable choice. > > Second question has to do with comments Robert Dober made like '10 times > > slower' and '50 times faster'. I'm assuming there's some benchmarking > > capability I need to learn more about. Could somebody point me? Also, is > > this capability available in IRB? > > Have you used the Benchmark module? It's the usual tool for getting > comparisons of different snippets that do the same thing as each > other. I haven't used it, but will definitely check it out. Thanks for the pointer. Best regards. Bill