Discussion: rand() v. rand(0.1) ?
Afficher un message
Vieux 15/09/2007, 20h54   #6
7stud --
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: rand() v. rand(0.1) ?

Matthew Rudy wrote:
> 7stud -- wrote:
>> Is there any difference between calling rand() and rand(0.1)?

>
> takes a look at the rdoc -
> http://www.ruby-doc.org/core/classes...l.html#M005955
>
> its defined as "rand(max=0)"
> ie. calling rand() is exactly the same as rand(0)
>
> also it "Converts max to an integer using max1 = max.to_i.abs"
> ie. max = 0.1 -> max1 = 0.1.to_i.abs = 0
> ie. rand() results in the same behaviour as rand(0.1)


That was my analysis too, however pickaxe2 has some code on p. 138 that
calls rand(0.1).
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
 
Page generated in 0,04272 seconds with 9 queries