Warning: The magic method NinjaFormsAddonManager\WordPress\Plugin::__wakeup() must have public visibility in /www/frowarecom_769/public/current/web/app/plugins/ninja-forms-addon-manager/lib/wordpress/plugin.php on line 22

Deprecated: Creation of dynamic property NinjaFormsAddonManager\Plugin::$service is deprecated in /www/frowarecom_769/public/current/web/app/plugins/ninja-forms-addon-manager/includes/plugin.php on line 19

Deprecated: Creation of dynamic property SearchAndFilter::$frmqreserved is deprecated in /www/frowarecom_769/public/current/web/app/plugins/search-filter/search-filter.php on line 71

Deprecated: Creation of dynamic property Tribe__Events__Community__PUE::$pue_instance is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/PUE.php on line 47

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$eventListDateFormat is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 305

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$users_can_create is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 313

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$emailAlertsEnabled is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 316

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$emailAlertsList is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 319

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$blockRolesFromAdmin is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 321

Deprecated: Creation of dynamic property Tribe__Events__Community__Main::$blockRolesList is deprecated in /www/frowarecom_769/public/current/web/app/plugins/the-events-calendar-community-events/src/Tribe/Main.php on line 322

Deprecated: Implicit conversion from float 11.5 to int loses precision in /www/frowarecom_769/public/current/web/wp/wp-includes/class-wp-hook.php on line 85

Deprecated: Implicit conversion from float 11.5 to int loses precision in /www/frowarecom_769/public/current/web/wp/wp-includes/class-wp-hook.php on line 87

Deprecated: Creation of dynamic property EAddonsForElementor\Plugin::$controls_manager is deprecated in /www/frowarecom_769/public/current/web/app/plugins/e-addons-for-elementor/core/plugin.php on line 175

Deprecated: Creation of dynamic property Kinsta\Cache_Purge::$kinsta_cache is deprecated in /www/frowarecom_769/public/current/web/app/mu-plugins/kinsta-mu-plugins/cache/class-cache-purge.php on line 84

Deprecated: Creation of dynamic property Kinsta\KMP::$wp_cli is deprecated in /www/frowarecom_769/public/current/web/app/mu-plugins/kinsta-mu-plugins/class-kmp.php on line 93

Deprecated: Use of "self" in callables is deprecated in /www/frowarecom_769/public/current/web/app/plugins/wp-discourse/lib/discourse.php on line 225
Use Copilot to Write and Translate a Binary Search Algorithm | Frocentric Tech
Deprecated: Automatic conversion of false to array is deprecated in /www/frowarecom_769/public/current/web/app/plugins/ele-custom-skin/includes/enqueue-styles.php on line 22

Use Copilot to Write and Translate a Binary Search Algorithm

I learn best from reading, watching, and doing, which means I need various resources to create a robust mental model. When I’ve studied for interviews, colleges exams, and coding bootcamp, I’ll watch videos, complete LeetCode exercises, and write an explanation of the code. Copilot Labs serves as an additional resource giving me more context on why and how specific algorithms work.

I will use Copilot and Copilot Labs to write and understand a binary search algorithm in this blog post.

Prerequisites:

Ensure that you’ve installed the GitHub Copilot extension AND the GitHub Copilot Labs extension. Please note: GitHub Copilot is in technical preview, and thus not all users will be able to access this feature. Please join the waitlist if you’d like to sign up for the technical preview.

Image description

Writing Code with Copilot

Step 1: Open your IDE. For this example, I’m using Visual Studio Code via Codespaces. Type a comment that says, “Write a binary search algorithm.”

Image description

Step 2: Type the keyword “const” on a new line. This should trigger Copilot to provide suggested code to write a binary search algorithm. To accept the suggested code, press the TAB key.

Image description

Image description

Image description

Explaining Code with Copilot Labs

Step 3: Now, we can better understand what the code is accomplishing by converting the code into plain language. Let’s open the Copilot Labs sidebar.

Image description

Step 4: Highlight the code snippet, and on the top left-hand corner, choose “Explain.” Press the “Ask Copilot” button to generate a step-by-step explanation of what’s happening in the code snippet.

Image description

Image description

Translating Code to a Different Programming Language with Copilot Labs

Step 5: We can also convert this code snippet into Python (or any programming language of your choice). Navigate to the Language Translation of the Copilot Labs sidebar and choose the target language. Press the “Ask Copilot” button to view a version of the code snippet in a different language.

Image description

Image description

Follow GitHub and me on DEV for more updates on GitHub’s newest features!

If you have any feedback you want to share with the team at GitHub, use the Discussion board.