From: Florian Gilcher Date: 2009-02-26T00:41:57+09:00 Subject: Re: uniuq no On Feb 25, 2009, at 3:14 PM, Lars Haugseth wrote: > * 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.I you know some other way ,please >> say >> to create unique id . > > UUID¹ is a standard way of constructing unique identifiers, and a Ruby > library² exist already, so unless you require the identifiers to be > integers, I suggest you use that. > > [1] http://en.wikipedia.org/wiki/UUID > [2] http://wiki.github.com/assaf/uuid > > -- > Lars Haugseth > > "If anyone disagrees with anything I say, I am quite prepared not > only to > retract it, but also to deny under oath that I ever said it." -Tom > Lehrer > UUIDs can also be notated in an integer representation. It's just a bit long. There are multiple libraries, this example uses the gem uuidtools: >> UUID.timestamp_create.to_i 227941543066369752189048382045440381927 They are the best way to choose. Regards, Florian -- Florian Gilcher smtp: flo@andersground.net jabber: Skade@jabber.ccc.de gpg: 533148E2