Le 29 juin 2009 17:18, Lloyd Linklater a ñÄrit : > Any suggestions? >> ('a'..'z').to_a + ('0'..'9').to_a => ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] Or even : >> [ *'a'..'z', *'0'..'9' ] => ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] So, if you need to compute a large number of random strings, store the array aside in a constant : >> CHARS = [ *'a'..'z', *'0'..'9' ] => ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] Then, you can use it to build your string : >> def build_random_string(len) >> r = '' >> len.times { r << CHARS[rand(36)] } >> r >> end => nil >> build_random_string(10) => "fdf93xdwq5" Fred -- *shrug* At least if it's pronounced "*ah" it can't possibly be written "*chestershire"... (Dimitri Maziuk in the SDM)