On Feb 25, 2009, at 3:14 PM, Lars Haugseth wrote: > * Vetrivel Vetrivel <vetrivel.bksys / gmail.com> 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 . > > UUIDis 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