Ruby | Random uuid() function Last Updated : 17 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report Random#uuid() : uuid() is a Random class method which checks returns a random v4 UUID (Universally Unique IDentifier). Syntax: Random.uuid() Parameter: Random values Return: a random v4 UUID (Universally Unique IDentifier). Example #1 : Ruby # Ruby code for Random.uuid() method # loading library require 'securerandom' # declaring Random value date_a = SecureRandom.uuid # declaring Random value date_b = SecureRandom.uuid # uuid value puts "Random uuid form : #{date_a}\n\n" puts "Random uuid form : #{date_b}\n\n" Output : Random uuid form : 219474f0-60c5-43b4-8e7f-f91b5c5e1f38 Random uuid form : d6800817-c27b-4651-8d98-dc12eec46706 Example #2 : Ruby # Ruby code for Random.uuid() method # loading library require 'securerandom' # declaring Random value date_a = SecureRandom.uuid # declaring Random value date_b = SecureRandom.uuid # uuid value puts "Random uuid form : #{date_a}\n\n" puts "Random uuid form : #{date_b}\n\n" Output : Random uuid form : f74b43f6-8b9c-4cd1-aff2-177f517b77aa Random uuid form : baba4612-6931-46a0-aa8b-7a105fd2f194 Comment More infoAdvertise with us Next Article Ruby | Random srand() function M mayank5326 Follow Improve Article Tags : Ruby Ruby-Methods Ruby Random-class Similar Reads Ruby | Random ==() function Random#==() is a Random class method which checks whether the two random values are equal. Syntax: Random.==() Parameter: Random values Return: true - if random values are equal otherwise return false Example #1 : Ruby # Ruby code for Random.==() method # declaring Random value date_a = Random.new(1 1 min read Ruby | Random seed() function Random#seed() : seed() is a Random class method which returns seed value used to initialize the generator Syntax: Random.seed() Parameter: Random values Return: seed value used to initialize the generator Example #1 : Ruby # Ruby code for Random.seed() method # declaring Random value date_a = Random 1 min read Ruby | Random srand() function Random#srand() : srand() is a Random class method which returns system pseudo-random number. Syntax: Random.srand() Parameter: Random values Return: system pseudo-random number. Example #1 : Ruby # Ruby code for Random.srand() method # declaring Random value date_a = Random.srand() # new arbitrary r 1 min read Ruby | Random hex() function Random#hex() : hex() is a Random class method which checks returns a random hexadecimal string. Syntax: Random.hex() Parameter: Random values Return: a random hexadecimal string. Example #1 : Example for hex() method Ruby # Ruby code for Random.hex() method # loading library require 'securerandom' # 1 min read Ruby | Random new() function Random#new() : new() is a Random class method which creates a new PRNG using seed to set the initial state. Syntax: Random.new() Parameter: Random values Return: a new PRNG using seed to set the initial state. Example #1 : Ruby # Ruby code for Random.new() method # declaring Random value date_a = Ra 1 min read Ruby | Random new_seed() function Random#new_seed() : new_seed() is a Random class method which returns a random seed value. Syntax: Random.new_seed() Parameter: Random values Return: a random seed value Example #1 : Ruby # Ruby code for Random.new_seed() method # declaring Random value date_a = Random.new_seed() # new arbitrary ran 1 min read Like