Ruby gives some warning

A

Albert Schlef

(I'm using Ruby 1.8.6.)

The following expression...

rand(rand 3)

...makes ruby emit a warning: "warning: parenthesize argument(s) for
future version"

It seems that I have to write is as "rand(rand(3))". Why? What potential
problem could there be in "rand(rand 3)" ?
 
J

Justin Collins

Albert said:
(I'm using Ruby 1.8.6.)

The following expression...

rand(rand 3)

...makes ruby emit a warning: "warning: parenthesize argument(s) for
future version"

It seems that I have to write is as "rand(rand(3))". Why? What potential
problem could there be in "rand(rand 3)" ?

This does not happen in 1.8.7 or 1.9.1, so I assume they have found a
way around this.

Even "rand rand 3" works.

-Justin
 
A

Albert Schlef

Justin said:
This does not happen in 1.8.7 or 1.9.1, so I assume they have found a
way around this.

Justin, thanks for the info!

(I've just checked 1.8.7's ChangeLog, and, indeed, I saw that this
warning has been removed. I'll have to upgrade my Ubuntu.)
 

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,774
Messages
2,569,598
Members
45,157
Latest member
MercedesE4
Top