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. The Never Executed Loop

The Never Executed Loop

Scheduled Pinned Locked Moved The Weird and The Wonderful
ruby
13 Posts 10 Posters 1 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.
  • B Bernhard Hiller

    Just discovered that gem:

        private string DoSomething(string input)
        {
            int len = input.Length;
            //fill up, in case leading 0s were lost
            for (int i = len; i < len; i++)
                input = "0" + input;
    
    J Offline
    J Offline
    jeron1
    wrote on last edited by
    #3

    On the positive side, there's no bugs in code that's never executed.

    A L B 3 Replies Last reply
    0
    • J jeron1

      On the positive side, there's no bugs in code that's never executed.

      A Offline
      A Offline
      Adam R Harris
      wrote on last edited by
      #4

      I like the positive outlook you have.

      Don't comment your code - it was hard to write, it should be hard to read!

      1 Reply Last reply
      0
      • B Bernhard Hiller

        Just discovered that gem:

            private string DoSomething(string input)
            {
                int len = input.Length;
                //fill up, in case leading 0s were lost
                for (int i = len; i < len; i++)
                    input = "0" + input;
        
        B Offline
        B Offline
        BillW33
        wrote on last edited by
        #5

        Even if the loop was set up right that is not a great way to prepend zeros. :wtf:

        Just because the code works, it doesn't mean that it is good code.

        1 Reply Last reply
        0
        • J jeron1

          On the positive side, there's no bugs in code that's never executed.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          jeron1 wrote:

          there's no bugs

          That's not a correct statement, there could still be undetected bugs :)

          J T 2 Replies Last reply
          0
          • B Bernhard Hiller

            Just discovered that gem:

                private string DoSomething(string input)
                {
                    int len = input.Length;
                    //fill up, in case leading 0s were lost
                    for (int i = len; i < len; i++)
                        input = "0" + input;
            
            P Offline
            P Offline
            phil o
            wrote on last edited by
            #7

            What a fast algorithm!

            [Flags]
            public enum Bool {
            True, False, ForSure, Maybe, ProbablyNot, Depends, NotDecidedYet, Undefined
            }

            1 Reply Last reply
            0
            • J jeron1

              On the positive side, there's no bugs in code that's never executed.

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #8

              Ooops, I must correct my statement: that code is not thread-safe, it might be executed, and bad things would happen...

              1 Reply Last reply
              0
              • L Lost User

                jeron1 wrote:

                there's no bugs

                That's not a correct statement, there could still be undetected bugs :)

                J Offline
                J Offline
                jeron1
                wrote on last edited by
                #9

                If the code is never executed, it'll go undetected for a really looooong time. :-D

                1 Reply Last reply
                0
                • B Bernhard Hiller

                  Just discovered that gem:

                      private string DoSomething(string input)
                      {
                          int len = input.Length;
                          //fill up, in case leading 0s were lost
                          for (int i = len; i < len; i++)
                              input = "0" + input;
                  
                  H Offline
                  H Offline
                  Hassan Oumar Mahamat
                  wrote on last edited by
                  #10

                  Very funny :) . It happens sometimes!

                  1 Reply Last reply
                  0
                  • L Lost User

                    jeron1 wrote:

                    there's no bugs

                    That's not a correct statement, there could still be undetected bugs :)

                    T Offline
                    T Offline
                    TheGreatAndPowerfulOz
                    wrote on last edited by
                    #11

                    I'd like a list of all the undetected bugs, please!

                    If your actions inspire others to dream more, learn more, do more and become more, you are a leader.-John Q. Adams
                    You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering.-Wernher von Braun
                    Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.-Albert Einstein

                    1 Reply Last reply
                    0
                    • R Ravi Bhavnani

                      Cool.  An O(zero) loop. ;P /ravi

                      My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                      S Offline
                      S Offline
                      Sergey Alexandrovich Kryukov
                      wrote on last edited by
                      #12

                      Brilliant note, Ravi.

                      —SA

                      Sergey A Kryukov

                      R 1 Reply Last reply
                      0
                      • S Sergey Alexandrovich Kryukov

                        Brilliant note, Ravi.

                        —SA

                        Sergey A Kryukov

                        R Offline
                        R Offline
                        Ravi Bhavnani
                        wrote on last edited by
                        #13

                        :) /ravi

                        My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                        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