From: Carlos Date: 2001-12-17T00:02:08+09:00 Subject: [ruby-talk:28686] Re: using ranges with rand > With ruby's great range feature, I would think it'd be possible to use > rand in conjunction with them...rather than doing something like > rand(100)+1000 to get to the desired starting point...i can think of > varous methods for achieving this, just wondering if there was a ruby > way about it :-) Here's a slow approach, I don't know about its ruby-wayness(?) :) ----- class Range def rand r = first Kernel::rand(length).times do r = r.succ end r end end (100..1000).rand # => 328 ('abcd'..'cdba').rand # => "ccge" ----- But it's (randomly) very slow with big ranges.