Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. Bool expression??

Bool expression??

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharplinqfunctionalquestion
24 Posts 13 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P PIEBALDconsult

    Then it should be

    return x ;

    // If I ever catch any of you writing it as
    //
    // if (x == true)
    // return true;
    // else
    // return false;
    //
    // I'll have you tied to an anthill and covered in honey!

    V Offline
    V Offline
    Vasudevan Deepak Kumar
    wrote on last edited by
    #21

    PIEBALDconsult wrote:

    I'll have you tied to an anthill and covered in honey!

    Cute. This should get a Vote of '5'.

    Vasudevan Deepak Kumar Personal Homepage
    Tech Gossips
    A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

    1 Reply Last reply
    0
    • B BadKarma

      No time or effort should be spared in the process of education of the younger generation. Even better would be.

      return (x == true) ? true : false;
      

      ;P

      codito ergo sum

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #22

      With longer conditions and expressions, ternary operator becomes tedious to debug. X|

      Vasudevan Deepak Kumar Personal Homepage
      Tech Gossips
      A pessimist sees only the dark side of the clouds, and mopes; a philosopher sees both sides, and shrugs; an optimist doesn't see the clouds at all - he's walking on them. --Leonard Louis Levinson

      1 Reply Last reply
      0
      • E Erich Ledesma

        I found this code somewhere:

        ...
        if (x == true)
        return true ;
        else
        return false ;

        Actual code was the body of a C# 3 lambda expression. Anyway, horrible.

        P Offline
        P Offline
        Paul Conrad
        wrote on last edited by
        #23

        :eek: So much for just doing a return x==true; If x is a bool, then just a simple return of x will work :-\

        "I guess it's what separates the professionals from the drag and drop, girly wirly, namby pamby, wishy washy, can't code for crap types." - Pete O'Hanlon

        1 Reply Last reply
        0
        • E Erich Ledesma

          I found this code somewhere:

          ...
          if (x == true)
          return true ;
          else
          return false ;

          Actual code was the body of a C# 3 lambda expression. Anyway, horrible.

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #24

          I considered creating a new thread for this, but (obviously) decided not to. I spent yesterday at the "Heroes happen {here}" event (in Phoenix) and most of the demoes in the "developers' track" was presented by a "developer evangelist", and it seemed like every one of his methods that returned a bool was written in that form. :mad:

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups