main.rb344 chars11 linesExplanation:
generate_password method takes an optional parameter length and a list of symbols.chars variable contains all the possible characters that can be used to generate the password - lowercase and uppercase letters, digits and the provided symbols.password variable is initialized as an empty string.length number of times. In each iteration, a random character is selected from the chars array using the sample method and added to the password array.password array is joined to form a string and returned.gistlibby LogSnag