Forum: Ruby Ruby gives some warning

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2008-12-28 15:52
(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)" ?
6e366eb5a71be2bad7f383d42aeb4788?d=identicon&s=25 Justin Collins (Guest)
on 2008-12-28 21:49
(Received via mailing list)
Albert Schlef wrote:
> 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
699c00ad35f2755810b4aa5f423d73e2?d=identicon&s=25 Albert Schlef (alby)
on 2008-12-29 10:55
Justin Collins wrote:
> 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.)
This topic is locked and can not be replied to.