I have been trying to generate a random string. One approach in, say,
pascal would be something like this:
function GetRandomChar: char;
var
r: integer;
begin
r := random(36);
case r of
0..25: result := chr(ord('a') + r);
else : result := chr(ord('0') + r);
end;
end;
I know that there is something like "a".next but I need something more
like "a" + some_random_value. Even though it is more terse than the
Pascal, I am trying to avoid something time consuming and inelegant like
s = "a"
rand(26).times do {s.next!}
Any suggestions?
--
Posted via http://www.ruby-forum.com/.