Vetrivel Vetrivel wrote:
> I want to create new unique id in ruby.I have used the following
> coding.But I don''t know whether it works perfectly or not.
> 
>  t = Time.new
>  p "%10.5f" % t.to_f
> 
> does it give unique value always.

This might be better:

d = Time.new
t = d.to_f
puts t

r = rand
puts r

p_id = $$
puts p_id

new_id = t + 10000000 * r + 10000000 * p_id
p new_id

-- 
Posted via http://www.ruby-forum.com/.