Possible bug in ruby interpreter

P

pp

Hi there,

I found that the expression:

1*(rand (1) + 1)

will often evaluate to 0. Eliminating the space between rand and
( makes the problem go away. Is this a bug?

-pp

ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.8.2]
 
R

Robert Klemme

2007/7/19 said:
Hi there,

I found that the expression:

1*(rand (1) + 1)

will often evaluate to 0. Eliminating the space between rand and
( makes the problem go away. Is this a bug?

I'm afraid, the bug is in your keyboard or further up the "invocation"
chain. :)

rand (1) + 1 is parsed as rand( 1 + 1 ) which sometimes will evaluate
to 0. Method brackets need to appear directly after the identifier.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top