Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Ruby: Random Alphanumeric String

DZone's Guide to

Ruby: Random Alphanumeric String

·
Free Resource
generate random alphanumeric string 'size' characters long

size = 8; (1..size).map{([*('a'..'z')]+[*('A'..'Z')]+[*(1..9)].map{|n|n.to_s}).instance_eval{self[rand(self.size)]}}.join
Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}