LAB: How Do I…?

A focused workshop for working developers who need to use AI right now, in real projects, under real time pressure.
As programmers, we have learned how to expertly search Google for any given problem. We've even learned how to "ask the right question" to maximize the search results.
If we end up on StackOverflow, we know that the marked answer is not always correct. If we're on GitHub, we know to check the commit date on the README to ensure we're not using old code.
In this new day of AI, we can shorten these search/copy/paste loops by understanding the cutoff date of whatever model we're working with, and then reviewing the answer for "correctness". That's a big topic, which we'll cover later in the "Is This Code Crap?" section.
Using Copilot
To keep things simple, this lab will focus on Copilot but feel free to use whatever tool you've chosen - it should work the same provided you're using the same LLM.
Before we get started, it's important to understand that Copilot works in "modes", sort of like Vim. These modes are "Ask", "Edit", and "Agent". We'll see all of them, but ask will always return text and not update files. Edit will do a single pass and edit things for you, and Agent will do a bunch of things for you and try to fix any problems it might have caused.
Confused? You're not alone. This is a questionable UX decision that is likely to be fixed in future releases. For now, set your mode to the default "Ask" and the model to Claude Sonnet 4 (or whatever the latest is):

Question 1: How to do a for loop?
- Ask the question:
how do I do a for loop?
The result is a generic answer, covering popular languages. This is should be close to what you see:

This answers the question we asked, but the not what we really want to know. When prompting, it's good to be specific as you can because you're communicating with an algorithm, and it's doing its best to understand you, but sometimes you need to help it along. Let's try again.
Question 2: How to do a for loop in Rust?
- Ask the question again, but be specific about your language of choice (such as
how do I do a for loop in Rust).
I don't know Rust, but it would be fun to learn it at some level! Replace the language here as you like - have some fun!
This reply is much more focused and will hopefully answer our question correctly. This is where cutoff dates come in! If Rust is changing rapidly, this answer might be obsolete! I don't think that's the case, however.

It looks like there are more than a few ways to iterate over a collection in Rust. What we see here is basic… but is it possible to do something more advanced? This is a natural question to ask and will tell us a lot about Rust's capabilities
Let's see if Rust can do tail recursion. If you don't know what that is - ask! Try prompting for what is tail recursion and why is it useful:

That's useful to know! Chat sessions can not only answer questions, but also help you learn new concepts along the way. But let's get back to the topic at hand:
how do I do a loop in Rust using tail recursion
A bit of a long answer, but we also get a tease about how to optimize things with loop:

This is a great explanation, at least in summary form to get started. We can ask for more details here, if we need, and dive in where things get interesting.
For instance: why does loop give better performance? Feel free to keep going - that's the point of this lab! We have questions, and rather than Googling constantly and reading StackOverflow answers or someone's random blog, we have answers flowing to us right here, in our editor.
A focused workshop for working developers who need to use AI right now, in real projects, under real time pressure.