1
00:00:00,750 --> 00:00:02,950
Hello and welcome to this lecture.

2
00:00:03,000 --> 00:00:12,210
In this lecture be showing you how to use comments with your ruby code command comments can be useful

3
00:00:12,210 --> 00:00:16,750
for a variety of reasons they can be used to explain your code.

4
00:00:16,860 --> 00:00:21,740
Comments are also ignored when the code executes or runs.

5
00:00:21,750 --> 00:00:26,750
Comments can be used for trouble shooting and testing.

6
00:00:26,750 --> 00:00:30,260
Key is for testing and also for troubleshooting.

7
00:00:30,270 --> 00:00:38,580
There are two types of comments you've got a single line comment and also a mauti line comment to illustrate

8
00:00:38,580 --> 00:00:40,520
how comments are used.

9
00:00:40,530 --> 00:00:48,560
I got my text open so I'm just going to first force feed this far as it would be far too far.

10
00:00:48,890 --> 00:00:56,970
As I now see it inside my documents are a core and it's comments

11
00:00:59,370 --> 00:01:09,060
to dot are we have already got a fire call comments I just made his comments to be a big C so I'm just

12
00:01:09,060 --> 00:01:15,350
going to write some commands here first to be going to be put them for 7.

13
00:01:15,610 --> 00:01:22,240
I am going to do a puts together and when I say hello world or something.

14
00:01:24,270 --> 00:01:25,080
Well.

15
00:01:25,430 --> 00:01:26,030
Ah right.

16
00:01:26,040 --> 00:01:26,620
I'm going to do.

17
00:01:26,640 --> 00:01:36,480
I'm just going to copy this code and pasted down here just to save some time and change some techs here.

18
00:01:36,480 --> 00:01:43,710
Just say thanks for watching.

19
00:01:46,710 --> 00:01:50,860
K. And I changed it to 7 for it.

20
00:01:50,980 --> 00:01:55,060
All right so how do you use a single line comment.

21
00:01:55,080 --> 00:01:57,220
There are several ways you can use a comet.

22
00:01:57,280 --> 00:02:04,200
You can put a comment that's just the top before the code so if there for example I wanted to explain

23
00:02:04,200 --> 00:02:08,140
something about this code I'll use a single line comment.

24
00:02:08,190 --> 00:02:13,880
The symbol is that just a hash tag voicing a line comment and then I can write the comment.

25
00:02:13,890 --> 00:02:16,380
I can see hoods

26
00:02:18,580 --> 00:02:27,480
introduces or put in place if a single

27
00:02:29,700 --> 00:02:32,230
line carry.

28
00:02:33,870 --> 00:02:36,240
Return.

29
00:02:42,340 --> 00:02:43,630
Output.

30
00:02:43,670 --> 00:02:52,580
So what this is saying basically when you run this command to our fate has put this number to also leave

31
00:02:52,720 --> 00:02:56,780
a space underneath basically what is so loose.

32
00:02:56,840 --> 00:03:04,080
A comment this way it does actually interfere with the code everything the commands will still work.

33
00:03:04,430 --> 00:03:12,920
However if you decide to place a comment in front of the actual command like so then that means this

34
00:03:12,920 --> 00:03:16,460
command will not run when the code executes.

35
00:03:16,760 --> 00:03:21,740
Okay I'll do the because when the code execute comments are ignored.

36
00:03:21,740 --> 00:03:26,320
So if you persist in their comments you don't want the code that affected your players to comment.

37
00:03:26,360 --> 00:03:28,670
But for the record like I've done here.

38
00:03:28,900 --> 00:03:34,350
So if I want to switch let's put this copy this a few times.

39
00:03:35,160 --> 00:03:38,980
Maybe there's more to Paul lying comments.

40
00:03:39,110 --> 00:03:40,480
Put another one there.

41
00:03:40,670 --> 00:03:41,670
Okay.

42
00:03:42,020 --> 00:03:48,230
So if I wanted if I had several lines of code and wanted to comment everything from that line.

43
00:03:48,440 --> 00:03:55,330
So rather than use a single line only Twan I can multiple comment then I just took a course to and you

44
00:03:55,330 --> 00:03:56,670
type in biggie.

45
00:03:56,720 --> 00:04:03,720
You have to see when it begins and you have to also tell it when it ends and the do equals it.

46
00:04:04,140 --> 00:04:07,170
It is very important he is it begin and end.

47
00:04:07,280 --> 00:04:14,610
So if I execute this code the only thing I expect to be outputted on the screen is this one is 7 for

48
00:04:14,620 --> 00:04:16,520
7 and businesses.

49
00:04:16,520 --> 00:04:17,650
Hello world.

50
00:04:17,660 --> 00:04:26,120
This will be ignored and this free line of code also be ignored so let me say that and let me run to

51
00:04:26,120 --> 00:04:28,570
run that I need to open up my command prompt.

52
00:04:28,690 --> 00:04:39,290
I am going to use guitar bass command line which is this and I am going to type in the name of off so

53
00:04:39,290 --> 00:04:42,930
to read the far and I'm just going to change territory to where I sit.

54
00:04:43,010 --> 00:04:48,950
I saved it in mind documents folder and the name of the cards calls comments too.

55
00:04:48,950 --> 00:04:53,630
So I'm going to use Ruby to interact thus far by calling the name.

56
00:04:53,730 --> 00:05:01,540
I see Ruby followed by the name on the far comments to dot RB and the press enter.

57
00:05:01,600 --> 00:05:03,080
You can see this.

58
00:05:03,260 --> 00:05:04,120
You can see the code.

59
00:05:04,130 --> 00:05:12,740
Now if I open up my text editor I just want to minimize that so you can see which parts of the code

60
00:05:12,740 --> 00:05:17,270
was executed and which part didn't execute.

61
00:05:17,300 --> 00:05:21,430
So you can see the puts 747 that one executed.

62
00:05:21,880 --> 00:05:24,110
He can see the Heller was executed.

63
00:05:24,110 --> 00:05:26,070
The other three dozen lists lie.

64
00:05:26,090 --> 00:05:27,430
One two three.

65
00:05:27,500 --> 00:05:30,510
And this did not because they all being commented out.

66
00:05:30,680 --> 00:05:38,210
So that's basically how you use comments in Ruby it's going to be very important as you get more acquainted

67
00:05:38,240 --> 00:05:42,610
with the Ruby language you're going to be using to use comments a lot.

68
00:05:42,740 --> 00:05:43,340
So that's it.

69
00:05:43,340 --> 00:05:44,310
Thanks for watching.

70
00:05:44,320 --> 00:05:44,980
Bye for now.
