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. loops and stuff

loops and stuff

Scheduled Pinned Locked Moved The Weird and The Wonderful
8 Posts 5 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.
  • L Offline
    L Offline
    loctrice
    wrote on last edited by
    #1

    Foo foo = null;
    for(Foo bar: Foobars){
    foo = bar;
    }

    if(foo == null){
    return someErroR;
    }

    Then also:

    int i = 0;
    for(String s : stringArray){
    if(i > 0){
    stringArray[i] = joinCharacter + stringArray[i];
    }
    i++;
    }

    Elephant elephant elephant, sunshine sunshine sunshine

    B 1 Reply Last reply
    0
    • L loctrice

      Foo foo = null;
      for(Foo bar: Foobars){
      foo = bar;
      }

      if(foo == null){
      return someErroR;
      }

      Then also:

      int i = 0;
      for(String s : stringArray){
      if(i > 0){
      stringArray[i] = joinCharacter + stringArray[i];
      }
      i++;
      }

      Elephant elephant elephant, sunshine sunshine sunshine

      B Offline
      B Offline
      Brisingr Aerowing
      wrote on last edited by
      #2

      The second one would fall flat on its face in C#. Does it actually work in Java? If it does, that's a huge WTF.

      What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

      L N 2 Replies Last reply
      0
      • B Brisingr Aerowing

        The second one would fall flat on its face in C#. Does it actually work in Java? If it does, that's a huge WTF.

        What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

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

        Are you talking about the foreach syntax?

        Elephant elephant elephant, sunshine sunshine sunshine

        B 1 Reply Last reply
        0
        • L loctrice

          Are you talking about the foreach syntax?

          Elephant elephant elephant, sunshine sunshine sunshine

          B Offline
          B Offline
          Brisingr Aerowing
          wrote on last edited by
          #4

          No, the modification of the collection while looping it.

          What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

          Z 1 Reply Last reply
          0
          • B Brisingr Aerowing

            No, the modification of the collection while looping it.

            What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

            Z Offline
            Z Offline
            ZurdoDev
            wrote on last edited by
            #5

            Brisingr Aerowing wrote:

            No, the modification of the collection while looping it.

            I've had issues trying to remove elements from a collection while looping but I have not had an issue just changing a value of the collection items, have you?

            There are only 10 types of people in the world, those who understand binary and those who don't.

            R 1 Reply Last reply
            0
            • B Brisingr Aerowing

              The second one would fall flat on its face in C#. Does it actually work in Java? If it does, that's a huge WTF.

              What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

              N Offline
              N Offline
              Nathan Minier
              wrote on last edited by
              #6

              Hate to say it, but that should work just fine, even in a C# foreach. It's just the product of a deranged mind.

              "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

              B 1 Reply Last reply
              0
              • N Nathan Minier

                Hate to say it, but that should work just fine, even in a C# foreach. It's just the product of a deranged mind.

                "There are three kinds of lies: lies, damned lies and statistics." - Benjamin Disraeli

                B Offline
                B Offline
                Brisingr Aerowing
                wrote on last edited by
                #7

                I've had code like that crash several times. It seemed kinda hit or miss. Never figured out what happened.

                What do you get when you cross a joke with a rhetorical question? The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism. Do questions with multiple question marks annoy you???

                1 Reply Last reply
                0
                • Z ZurdoDev

                  Brisingr Aerowing wrote:

                  No, the modification of the collection while looping it.

                  I've had issues trying to remove elements from a collection while looping but I have not had an issue just changing a value of the collection items, have you?

                  There are only 10 types of people in the world, those who understand binary and those who don't.

                  R Offline
                  R Offline
                  raddevus
                  wrote on last edited by
                  #8

                  I believe Brisingr is thinking of when you iterate through a enumerable and you attempt to update the ienumerable item. Like the following:

                  for(String s : stringArray){
                  if(i > 0){
                  // if you attempt to update the s var.
                  s = joinCharacter + stringArray[i];
                  }
                  i++;
                  }

                  It's fine to update the other referenced collection (stringArray[i]). Brisingr probably was just thinking about that. Not trying to start a battle by speaking for him though.

                  My book, Launch Your Android App, is available at Amazon.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