Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: curious use of LENGTH?

From: rotenca:telvia:it at: 31-Jan-2002 14:51

Hi Joel,
> s: make string! 0 > foreach file dir [ > append s file > while [((length? s) // max) <> 0] [append s " "] > if (length? s) > 60 [ > print s > clear s > ] > ] > if length? s [print s] > ] > Notice the last line -- I have no clue what it means in REBOL to > use an integer-valued expression as the condition of IF. I tried > some small experiments, and in every case IF treated an integer > as TRUE (including zero and negative values). I then tried > variations on a string value FOO in the phrase IF LENGTH? FOO ... > and always got the equivalent of TRUE, regardless of its length. > (The only exception was when FOO was UNSET, in which case I got > an error...) >From Core 3-23 about 'if:
The condition is normally an expression that evaluates to true or false; however, other values can also be supplied. Only a false or a none value prevents the block from being evaluated. All other values (including zero) are treated as true, and cause the block to be evaluated.
> Any suggestions on why the above wasn't written simply as > > PRINT S
If 's would be empty, it would print a newline. --- Ciao Romano