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. if I don't exist OR ....

if I don't exist OR ....

Scheduled Pinned Locked Moved The Weird and The Wonderful
csharp
12 Posts 10 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.
  • C Offline
    C Offline
    codemunch
    wrote on last edited by
    #1

    Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

    S L D P C 7 Replies Last reply
    0
    • C codemunch

      Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

      S Offline
      S Offline
      StM0n
      wrote on last edited by
      #2

      maybe it's some philosophic-thing...

      (yes|no|maybe)*

      1 Reply Last reply
      0
      • C codemunch

        Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

        L Offline
        L Offline
        leppie
        wrote on last edited by
        #3

        Sanity checking? ;P

        xacc.ide - now with IronScheme support
        IronScheme - 1.0 alpha 2 out now

        1 Reply Last reply
        0
        • C codemunch

          Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

          D Offline
          D Offline
          darkelv
          wrote on last edited by
          #4

          The object might feel a bit of insecure and thus need to re-assure itself sometimes.

          1 Reply Last reply
          0
          • C codemunch

            Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

            P Offline
            P Offline
            Pete OHanlon
            wrote on last edited by
            #5

            It's an AI piece of code - it's the equivalent to "I think therefore I am, you aren't me so you don't matter."

            Deja View - the feeling that you've seen this post before.

            My blog | My articles

            L 1 Reply Last reply
            0
            • P Pete OHanlon

              It's an AI piece of code - it's the equivalent to "I think therefore I am, you aren't me so you don't matter."

              Deja View - the feeling that you've seen this post before.

              My blog | My articles

              L Offline
              L Offline
              Luc Pattyn
              wrote on last edited by
              #6

              AI is much clearer in VB, as in

                  If (Me Is Nothing) Then
                      ' I don't exist, so I can't think (straight? at all?)
                  End If
              

              :laugh: :laugh:

              Luc Pattyn [Forum Guidelines] [My Articles]


              This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


              P 1 Reply Last reply
              0
              • C codemunch

                Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

                C Offline
                C Offline
                Chris Maunder
                wrote on last edited by
                #7

                OK, so you'd not want to assign a value to an object that was null, but it brings up an interesting discussion on the use of "if (this != null)". Take a look at this discussion on MSN[^] about this != null in C#.

                cheers, Chris Maunder

                CodeProject.com : C++ MVP

                1 Reply Last reply
                0
                • L Luc Pattyn

                  AI is much clearer in VB, as in

                      If (Me Is Nothing) Then
                          ' I don't exist, so I can't think (straight? at all?)
                      End If
                  

                  :laugh: :laugh:

                  Luc Pattyn [Forum Guidelines] [My Articles]


                  This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                  P Offline
                  P Offline
                  peterchen
                  wrote on last edited by
                  #8

                  Luc Pattyn wrote:

                  Me Is Nothing

                  that is not philosophy, but an inferiority complex :D

                  We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                  blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist

                  L 1 Reply Last reply
                  0
                  • P peterchen

                    Luc Pattyn wrote:

                    Me Is Nothing

                    that is not philosophy, but an inferiority complex :D

                    We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                    blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist

                    L Offline
                    L Offline
                    Luc Pattyn
                    wrote on last edited by
                    #9

                    peterchen wrote:

                    inferiority complex

                    not being fluent in VB.NET does that to people; I'm just a C# guy. :-D

                    Luc Pattyn [Forum Guidelines] [My Articles]


                    This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                    P 1 Reply Last reply
                    0
                    • C codemunch

                      Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

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

                      if (this == null)
                      {
                      // I wasn't here; you never saw me
                      }

                      1 Reply Last reply
                      0
                      • C codemunch

                        Found this C# beauty in 3 places in a particular class i'm updating. if (this == null || ..... { // assigned values to self } I'm guessing the person that wrote that was going to be checking a field to see if it was null but none of the assignment code within the {} indicates what that might have been.

                        R Offline
                        R Offline
                        Roger Alsing 0
                        wrote on last edited by
                        #11

                        if (this == null || ..... { // assigned values to self } You can get into the true part there, you just have to do a bit of IL hacking. Since instance methods are like static methods with a "this" param as the first arg in il. you can invoke such method and pass null to "this" Im not saying you should do this, but its possible :-) I happened to get that problem when I was doing the subclass proxies for NAspect (our AOP framework) It works as long as you don't access any member variables :-P

                        Blog: http://www.rogeralsing.com Projects: http://www.puzzleframework.com

                        1 Reply Last reply
                        0
                        • L Luc Pattyn

                          peterchen wrote:

                          inferiority complex

                          not being fluent in VB.NET does that to people; I'm just a C# guy. :-D

                          Luc Pattyn [Forum Guidelines] [My Articles]


                          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                          P Offline
                          P Offline
                          peterchen
                          wrote on last edited by
                          #12

                          Luc Pattyn wrote:

                          not being fluent in VB.NET does that to people;

                          I'm not fluent, and that doesn't make me feel inferior. Conclusion? I'm not people. Wow, that was easy ;) In case you missed it, I meant the language (not you) expresses its inferiority complex with "me is nothing"

                          We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
                          blog: TDD - the Aha! | Linkify!| FoldWithUs! | sighist

                          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