Search Results

Search found 2 results on 1 pages for 'oym'.

Page 1/1 | 1 

  • Checking negative of a condition

    - by oym
    What is the (slightly pejorative) term for checking the negative of a condition (rather than the positive which is often more readable): e.g. if(!someVar) { return null; } else { return doSomethingInteresting(); } instead of doing this (which is arguably more readable) if(someVar) { return doSomethingInteresting(); } else { return null; } I vaguely remember there being a term for this; something in the same spirit as the term Yoda conditions.

    Read the article

  • Play Framework Form "fold" method naming rationale

    - by oym
    Play Framework's (2.x) Form class has a method called fold who's usage is indicated as: anyForm.bindFromRequest().fold( f => redisplayForm(f), t => handleValidFormSubmission(t) ) Essentially, the first function parameter is what gets executed on binding failure, and the 2nd on binding success. To me it seems similar to the 'success' and 'error' callbacks of jquery's ajax function. My question is why did the Play developers call the method "fold"? As a disclaimer I am new to Scala, but I am failing to see the connection between this and the functional Scala fold operation. The only similarity is that it is a higher order function; but I don't see any combining that is taking place, nor does it delegate internally in its implementation to any of the Scala fold functions.

    Read the article

1