AI Native Development
English🇬🇧
English🇬🇧
  • Introduction
  • Contributing to the Project
  • Introduction
    • AI Native Development
    • AI-Readable Documentation
    • Types of AI Coding Tools
  • Basic
    • Code Completion
    • Generating Code from Comments
    • Generating Comments
    • Code Refactoring
  • Patterns
    • AI Native Documentation
    • AI-Readable Naming Rules
    • Test Development with AI
    • Context Directory
    • Prompt Knowledge Sharing
    • Reinventing the Wheel
Powered by GitBook
On this page
  1. Basic

Generating Code from Comments

GitHub Copilot can also generate new code based on conditions specified by developers. For example, you can generate code by specifying the following conditions:

You can specify the following conditions to generate a new function:

// Function name: calculateAverage
// Function argument: numbers (array)
// Function return type: number

By specifying these conditions, GitHub Copilot generates the following code:

function calculateAverage(numbers: number[]): number {
    // Calculate the average of the array
    const sum = numbers.reduce((a, b) => a + b);
    return sum / numbers.length;
}

You can provide more complex definitions as well.

Last updated 1 year ago