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
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!