# Possible bug in ruby interpreter

**URL:** <https://www.ruby-forum.com/t/possible-bug-in-ruby-interpreter/109814>\
**Category:** Ruby\
**Created:** [July 19, 2007, 9:25am UTC](https://www.ruby-forum.com/t/possible-bug-in-ruby-interpreter/109814 "2007-07-19T09:25:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pppppp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@pppppp](https://www.ruby-forum.com/u/pppppp)\
**Post date:** [July 19, 2007, 9:25am UTC](https://www.ruby-forum.com/t/possible-bug-in-ruby-interpreter/109814/1 "2007-07-19T09:25:48Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![pppppp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/71e660/32.png) [@pppppp](https://www.ruby-forum.com/u/pppppp)\
**Post date:** [July 19, 2007, 10:22am UTC](https://www.ruby-forum.com/t/possible-bug-in-ruby-interpreter/109814/2 "2007-07-19T10:22:55Z")

</div>

2007/7/19, pp [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> 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
