[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

an interesting one-liner to ponder

John Joyce

11/17/2007 1:17:00 AM

Here's an interesting one-liner to ponder.

0.step(100, rand) { |x| puts x }

Think of timers, for games or whatever, you could easily alter the
pseudo-random stepping increment to make it bigger but random, or
have broader ranges of randomness.

The interval will not be obvious to the user.


1 Answer

Robert Klemme

11/17/2007 4:26:00 PM

0

2007/11/17, John Joyce <dangerwillrobinsondanger@gmail.com>:
> Here's an interesting one-liner to ponder.
>
> 0.step(100, rand) { |x| puts x }
>
> Think of timers, for games or whatever, you could easily alter the
> pseudo-random stepping increment to make it bigger but random, or
> have broader ranges of randomness.
>
> The interval will not be obvious to the user.

But constant. I am not sure I understand what this is good for. Can
you share your ideas?

Kind regards

robert


--
use.inject do |as, often| as.you_can - without end