From the course: AI-Powered Development: GitHub Copilot in Visual Studio Code

Unlock this course with a free trial

Join today to access over 25,300 courses taught by industry experts.

Use comments to guide completion

Use comments to guide completion

GitHub Copilot doesn't just respond to code, it also pays close attention to our comments, especially when we're writing them in natural language above or next to our code. For example, in this Python file, I have four sections of comments. In many cases, a well-written comment can act like a mini prompt helping Copilot understand what we're trying to do and generate more relevant suggestions. So my goal for the first function is to filter a list of integers returning only those that are greater than a given threshold. So I've written two sets of comments that express that goal. Naturally there are many ways to write comments to express your intent and the way we phrase them can influence copilot suggestions. So I'll go up here to line four and I'll type in def and you see that it's suggesting a function called filter greater than threshold that takes two parameters. Let's accept that one. Then we'll move down to line 10 and see what we get here. This one is called filter numbers…

Contents