Ruby Random uuid()函数
Random#uuid() : uuid()是一个随机类方法,它检查返回一个随机的v4 UUID(通用唯一标识符)。
语法。Random.uuid()
参数。随机值
返回:一个随机的v4 UUID(普遍唯一的IDentifier)。
例子 #1 :
# 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"
输出:
Random uuid form : 219474f0-60c5-43b4-8e7f-f91b5c5e1f38
Random uuid form : d6800817-c27b-4651-8d98-dc12eec46706
例子 #2 :
# 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"
输出:
Random uuid form : f74b43f6-8b9c-4cd1-aff2-177f517b77aa
Random uuid form : baba4612-6931-46a0-aa8b-7a105fd2f194