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. General Programming
  3. C#
  4. (Current) AI Rant.

(Current) AI Rant.

Scheduled Pinned Locked Moved C#
data-structurescsharpvisual-studioai-modelsai-coding
4 Posts 2 Posters 2 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
    Lost User
    wrote on last edited by
    #1

    Me, wanting to "peek" the "last" entry in a ConcurrentQueue, because the "next" entry I will enqueue needs "prior info" if it exists. I can use ToArray, and GetEnumerator. Surprising .Last() compiles but I thought I'd "Bing" anyway. Me: peek last entry in concurrentqueue Copilot with GPT-4:

    Quote:

    Certainly! In C#, if you want to peek at the last entry in a ConcurrentQueue, you can use the TryPeek method. Here’s an example:

    (Some "wrong" / right code).

    Quote:

    In this example, the TryPeek method allows you to examine the last item in the queue without removing it. If the queue is empty, it returns false, and you can handle that case accordingly. If you have any more questions or need further assistance, feel free to ask! 😊

    MSDN re: TryPeek:

    Quote:

    Tries to return an object from the beginning of the ConcurrentQueue without removing it.

    Seems it can't differentiate a queue from a stack. Nice. VS is also getting more "aggressive" when it's getting it wrong.

    "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

    L L 3 Replies Last reply
    0
    • L Lost User

      Me, wanting to "peek" the "last" entry in a ConcurrentQueue, because the "next" entry I will enqueue needs "prior info" if it exists. I can use ToArray, and GetEnumerator. Surprising .Last() compiles but I thought I'd "Bing" anyway. Me: peek last entry in concurrentqueue Copilot with GPT-4:

      Quote:

      Certainly! In C#, if you want to peek at the last entry in a ConcurrentQueue, you can use the TryPeek method. Here’s an example:

      (Some "wrong" / right code).

      Quote:

      In this example, the TryPeek method allows you to examine the last item in the queue without removing it. If the queue is empty, it returns false, and you can handle that case accordingly. If you have any more questions or need further assistance, feel free to ask! 😊

      MSDN re: TryPeek:

      Quote:

      Tries to return an object from the beginning of the ConcurrentQueue without removing it.

      Seems it can't differentiate a queue from a stack. Nice. VS is also getting more "aggressive" when it's getting it wrong.

      "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

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

      It is not intelligent. Marketing sells it like it is, but we are far away from thinking machines. :thumbsup:

      Bastard Programmer from Hell :suss: "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      1 Reply Last reply
      0
      • L Lost User

        Me, wanting to "peek" the "last" entry in a ConcurrentQueue, because the "next" entry I will enqueue needs "prior info" if it exists. I can use ToArray, and GetEnumerator. Surprising .Last() compiles but I thought I'd "Bing" anyway. Me: peek last entry in concurrentqueue Copilot with GPT-4:

        Quote:

        Certainly! In C#, if you want to peek at the last entry in a ConcurrentQueue, you can use the TryPeek method. Here’s an example:

        (Some "wrong" / right code).

        Quote:

        In this example, the TryPeek method allows you to examine the last item in the queue without removing it. If the queue is empty, it returns false, and you can handle that case accordingly. If you have any more questions or need further assistance, feel free to ask! 😊

        MSDN re: TryPeek:

        Quote:

        Tries to return an object from the beginning of the ConcurrentQueue without removing it.

        Seems it can't differentiate a queue from a stack. Nice. VS is also getting more "aggressive" when it's getting it wrong.

        "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

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

        The good thing about the new "AI" tools is that they always give a reasonable and convincing looking answer.... especially when they are wrong.

        1 Reply Last reply
        0
        • L Lost User

          Me, wanting to "peek" the "last" entry in a ConcurrentQueue, because the "next" entry I will enqueue needs "prior info" if it exists. I can use ToArray, and GetEnumerator. Surprising .Last() compiles but I thought I'd "Bing" anyway. Me: peek last entry in concurrentqueue Copilot with GPT-4:

          Quote:

          Certainly! In C#, if you want to peek at the last entry in a ConcurrentQueue, you can use the TryPeek method. Here’s an example:

          (Some "wrong" / right code).

          Quote:

          In this example, the TryPeek method allows you to examine the last item in the queue without removing it. If the queue is empty, it returns false, and you can handle that case accordingly. If you have any more questions or need further assistance, feel free to ask! 😊

          MSDN re: TryPeek:

          Quote:

          Tries to return an object from the beginning of the ConcurrentQueue without removing it.

          Seems it can't differentiate a queue from a stack. Nice. VS is also getting more "aggressive" when it's getting it wrong.

          "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

          L Offline
          L Offline
          lmoelleb
          wrote on last edited by
          #4

          Besides AI getting it wrong: 1) If you have concurrent writers to the queue you do not know something else does not insert a new "last" item after you checked what it is. This can of course be solved with some locking, but then we are at the next point: 2) If you do not have concurrent writers you can just capture the last item to a variable as you enqueue it.

          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