Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.51 KB

code-completion.md

File metadata and controls

49 lines (36 loc) · 1.51 KB
title description category authors platforms level aliases
Code Completion
Simple code completion with GitHub Copilot
general
yuhattor
copilot
copilot-chat
lv3
/docs/general/code-completion
/docs/v/en/general/code-completion

Code Completion

Description

One of the simplest uses of GitHub Copilot is code completion. Code completion enhances developer productivity by offering potential code snippets as the developer is typing. For example, imagine defining a function in JavaScript. As you input the code below, GitHub Copilot will suggest potential code that could be used inside the function, such as the following code.

Example

Input Code
function calculateSum(a, b) {
    // Enter your code here
}
Result Suggested by Copilot
function calculateSum(a, b) {
    // Enter your code here
    const sum = a + b;
    return sum;
}

Exerecise

  • Exercise 1: Complete the calculateSum(a, b) function by utilizing GitHub Copilot's suggestions. Explore how different prompts or partial code inputs influence the suggestions made by Copilot.

Checklist for Further Learning

  • Did your code output resemble the sample code provided?
  • Is the outputted code robust? Is error handling considered? If not, how could you improve the code?
  • What prompts or context can you add to write more precise code?