in reply to Anybody use !!

This is confusing syntax although its operation is defined and it does "work". I would seek a better, more clear formulation. Also of course using $return is not the best choice of a name, use $accounts_validated or some other more descriptive term that describes the boolean nature of the return value.

Updated: Corrected the spelling of "formulation". Also, I would think that a very clear statement of what the $return value is, resolves the problems that ikegami points out. They can happen. I would not use side effects of an operator as a substitute for explicitly saying what you mean in a very clear way. The fact that we are even discussing what does "!!$return mean?", means that it shouldn't be used. It is confusing. And in my mind that is reason enough not to do it. Use some kind of "if", perhaps a ternary statement to resolve this down to an obvious boolean, $flag_all_ok, if necessary. Have the return statement return an obvious thing.

Replies are listed 'Best First'.
Re^2: Anybody use !!
by BrowserUk (Patriarch) on Dec 30, 2010 at 02:26 UTC
    This is confusing syntax

    You are confused by it?

      Typing "confuse" in Google, first hit:

      1. Cause (someone) to become bewildered or perplexed.
      2. Make (something) more complex or less easy to understand.

      So yes, I would say that this is more complex or less easy to understand.

      I am not bewildered, if that is what you meant.

        You evade my point.

        Are you, personally confused by what return !!$rv; does?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.
Re^2: Anybody use !!
by Anonymous Monk on Dec 30, 2010 at 08:13 UTC
    I would not use side effects of an operator as a substitute for explicitly saying what you mean in a very clear way.
    ! is a unary operator, and acts like a (pure) function with one mandatory argument. It returns the negated truth value of the argument passed in, regardless how it represents false values. There are no side effects involved at all.