Ruby | Random uuid() function
Last Updated :
17 Dec, 2019
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 :
require 'securerandom'
date_a = SecureRandom.uuid
date_b = SecureRandom.uuid
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 :
require 'securerandom'
date_a = SecureRandom.uuid
date_b = SecureRandom.uuid
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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...