WEBVTT

1
00:00:01.760 --> 00:00:07.360
So, we created this little utility function here to convert Fahrenheit to Celsius.

2
00:00:08.220 --> 00:00:14.620
Now I actually want to have a more flexible function, a function which accepts either

3
00:00:14.620 --> 00:00:21.700
a Fahrenheit or a Celsius value and then maybe some flag that indicates which kind of value

4
00:00:21.700 --> 00:00:27.060
it is and then performs the appropriate conversion depending on which kind of value was passed

5
00:00:27.060 --> 00:00:27.260
in.

6
00:00:28.760 --> 00:00:34.700
So, we could of course try to find a fitting function name which gets GitHub Copilot to

7
00:00:34.700 --> 00:00:44.020
suggest the right function code, but alternatively a very common and useful thing or trick you

8
00:00:44.020 --> 00:00:50.480
can use when working with GitHub Copilot is to add a comment where you describe the kind

9
00:00:50.480 --> 00:00:52.200
of code you want to generate.

10
00:00:52.420 --> 00:00:57.780
So you use the comment almost like a place to put a prompt that will be evaluated by

11
00:00:57.680 --> 00:01:06.760
GitHub Copilot because GitHub Copilot will evaluate the surrounding code around your

12
00:01:06.760 --> 00:01:09.320
cursor when generating the suggestions.

13
00:01:09.760 --> 00:01:15.280
It may even evaluate the entire code in the entire file for generating its suggestions.

14
00:01:15.280 --> 00:01:16.100
So it's smart.

15
00:01:16.260 --> 00:01:20.640
It's taking a look at the surrounding code and that's why you can add a comment here

16
00:01:22.160 --> 00:01:32.780
and say, function that takes either a Celsius or now it even suggests the comment here or

17
00:01:32.780 --> 00:01:36.800
a Fahrenheit temperature and converts it to the average temperature scale.

18
00:01:38.600 --> 00:01:41.220
So yeah, the comment indeed is what I want.

19
00:01:41.560 --> 00:01:43.540
I even get multiple suggestions here.

20
00:01:44.960 --> 00:01:49.560
So maybe I take the shorter one here and I can accept it by hitting tab.

21
00:01:51.560 --> 00:01:56.440
And that's of course kind of next level AI driven development because now I'm writing

22
00:01:56.440 --> 00:01:59.280
a comment for the AI with AI.

23
00:02:00.740 --> 00:02:05.980
And you can probably already see how that may speed up your development flow.

24
00:02:06.480 --> 00:02:08.320
So now here I have that comment.

25
00:02:09.400 --> 00:02:13.720
Actually I'll split it across multiple lines to make it a bit easier to read, to have it

26
00:02:13.720 --> 00:02:14.460
all on the screen.

27
00:02:15.220 --> 00:02:18.040
And you see, I'm getting a suggestion now here.

28
00:02:19.720 --> 00:02:23.580
Even though I did not type a single character, but I'm getting it because of this comment,

29
00:02:23.960 --> 00:02:25.620
which is of course very useful.

30
00:02:27.500 --> 00:02:32.240
By the way, if a suggestion disappears and you want to get it back, it often helps to

31
00:02:32.240 --> 00:02:37.060
just go back a line and then back to the line where you want the code to appear.

32
00:02:38.500 --> 00:02:42.380
So here it now suggests this line of code convert temperature.

33
00:02:43.020 --> 00:02:49.140
Again we have different suggestions here and we can also go to this completions panel to

34
00:02:49.120 --> 00:02:50.200
see if there are maybe more.

35
00:02:51.730 --> 00:02:57.360
Because here, as you saw before, you sometimes have more suggestions than in that quick popup.

36
00:02:57.640 --> 00:03:02.640
And you see now indeed it's loading more suggestions and it generated nine suggestions.

37
00:03:02.840 --> 00:03:07.980
And here you can see, since it seems to take a bit more time when using this panel here,

38
00:03:08.120 --> 00:03:10.440
I got more complete suggestions.

39
00:03:11.360 --> 00:03:15.020
I got the entire code block here instead of just the first line.

40
00:03:15.680 --> 00:03:21.060
So I will say that sometimes you will get entire code blocks here in the main code editor

41
00:03:21.060 --> 00:03:21.520
as well.

42
00:03:21.780 --> 00:03:23.580
It's not always just one line.

43
00:03:24.820 --> 00:03:30.740
It depends on the kind of code it needs to generate and probably also on how fast its

44
00:03:30.740 --> 00:03:32.240
backend currently is.

45
00:03:33.480 --> 00:03:38.820
So here, where it took more time, I got more suggestions and, well, this looks pretty good.

46
00:03:39.240 --> 00:03:45.120
I got the convert temperature function here suggested, which takes a temperature and a

47
00:03:44.960 --> 00:03:53.560
unit identifier, which is either an F or a C, and then it performs the actual conversion.

48
00:03:54.420 --> 00:03:57.640
And I got different variations of that.

49
00:03:58.160 --> 00:04:00.960
So yeah, that looks pretty good.

50
00:04:02.740 --> 00:04:08.260
So I'll take that first suggestion and yeah, sure, save them.

51
00:04:09.180 --> 00:04:14.820
And with that, I got this function here, fully generated by GitHub Copilot because

52
00:04:14.820 --> 00:04:17.740
of my comment, which I now of course can delete.

53
00:04:19.220 --> 00:04:25.440
But adding such comments and use them as a place to write your prompt or your instructions

54
00:04:25.440 --> 00:04:30.420
that define the kind of code that should be generated, that's another very important

55
00:04:30.420 --> 00:04:31.840
trick you should be aware of.

56
00:04:32.880 --> 00:04:35.480
And of course you can use such comments anywhere.

57
00:04:35.860 --> 00:04:39.800
You could use them inside of a function as well to add some extra instructions here,

58
00:04:39.980 --> 00:04:45.660
which could then be picked up by Copilot to generate more code in this place here in the

59
00:04:45.660 --> 00:04:46.020
function.

60
00:04:47.599 --> 00:04:53.600
All that is possible and all these are the little tips and tricks you must be aware of

61
00:04:53.600 --> 00:04:56.960
to use this feature, this extension efficiently.

