From: AW Date: 2002-08-21T05:30:53+09:00 Subject: the power of ruby Hi, As i get better writing ruby scripts (im pretty new), I often wonder if im not exploiting the power of the language or that i'm casting precedural language ideas onto my ruby scripts. I have here a little C program that would like some of you to Rubi-tize if possible, so that i can see how some of you that really know the language use it. [code]============================================ #include #include int I; /*-----------------------------*/ void dodot(int x){ while(x>0){ printf(" "); x--; } printf("*\n"); sleep(10); } /*-----------------------------*/ int main(int argc, char *argv[]) { while(1){ while(I<75){ dodot(I); I++; } while(I>0){ dodot(I); I--; } } return 0; } [/code]============================================= Here is my unimaginitive attempt. [code]============================================== WIDTH=78; def do_dot(i) i.times{print " "} puts "*"; end loop{ 0.upto(WIDTH-1){|i| do_dot(i); } WIDTH.downto(1){|i| do_dot(i); } } [/code]============================================= Thanks.