1
00:00:00,510 --> 00:00:01,470
Welcome back.

2
00:00:01,640 --> 00:00:08,550
And this week, we are going to look at another type of operators, the comparison operators, so comparison

3
00:00:08,550 --> 00:00:10,970
operators are the ones that you can see here.

4
00:00:10,980 --> 00:00:17,250
So double equal, not equal, less than greater than less than equal or greater equal.

5
00:00:17,490 --> 00:00:20,570
So now let's see how they are used in.

6
00:00:21,600 --> 00:00:25,830
First of all, let's create this variable called is equal.

7
00:00:27,390 --> 00:00:35,610
And it's going to be the result of the following operation, which means five equal equal three.

8
00:00:36,150 --> 00:00:37,890
So what does that do?

9
00:00:38,190 --> 00:00:45,230
Well, it checks if the value on the left hand side is the same as the value on the right hand side.

10
00:00:45,480 --> 00:00:48,310
So that's what this double equal sign does.

11
00:00:48,570 --> 00:00:55,270
So it's comparing two values to each other and it's going to give us a boolean result.

12
00:00:55,290 --> 00:01:00,320
So it says it's a boolean expression, even though we can simplify the boolean expression.

13
00:01:00,330 --> 00:01:01,210
So let's just do that.

14
00:01:01,560 --> 00:01:04,920
You can say it gives me the result directly, which is false.

15
00:01:05,080 --> 00:01:10,140
But of course, that's not what I wanted, because what I wanted is to display this operation here,

16
00:01:10,350 --> 00:01:18,300
which is just saying, OK, one side equal, equal the other side or is the one side the same value

17
00:01:18,300 --> 00:01:21,720
as the other side of this equation here?

18
00:01:22,020 --> 00:01:27,090
So if you do that, you will get a result, which is either false or true.

19
00:01:27,270 --> 00:01:31,770
So if we do the same with five equals equals five, then of course the result will be true.

20
00:01:32,130 --> 00:01:36,000
And in this case, it's super obvious because we can see those values.

21
00:01:36,180 --> 00:01:42,270
But let's say they are hidden behind a variable where you can't always see the variable value, then

22
00:01:42,270 --> 00:01:49,510
this will be a very useful operation because maybe you even want to do something based on that operation.

23
00:01:50,040 --> 00:01:55,470
So let's say if this condition is true, then you want to run some code, then it's going to be very

24
00:01:55,470 --> 00:01:58,700
important to do this type of comparison operations.

25
00:01:58,950 --> 00:02:03,440
And of course, this is also something that we are going to look at later on, which are if statements.

26
00:02:03,660 --> 00:02:08,190
But for now, this is our very simple operation that we have here.

27
00:02:08,550 --> 00:02:12,630
So now let's go ahead and print something onto our console.

28
00:02:13,140 --> 00:02:19,060
And I'm going to write is equal is plus is equal.

29
00:02:19,530 --> 00:02:23,610
So what I'm doing here is I'm using concatenation.

30
00:02:24,390 --> 00:02:25,560
So it's just.

31
00:02:26,910 --> 00:02:32,230
Using this strength and then it's converting this into a string and just saying whatever the value is.

32
00:02:32,610 --> 00:02:36,640
So if we run that we can see that is equal, is false.

33
00:02:37,140 --> 00:02:39,270
So our is equal, is false.

34
00:02:39,540 --> 00:02:46,920
So then, of course, our idee, which means our Android studio says, hey, you can convert concatenation

35
00:02:46,920 --> 00:02:47,660
to a template.

36
00:02:47,670 --> 00:02:48,560
So let's do that.

37
00:02:48,570 --> 00:02:50,130
And you can see what it does.

38
00:02:50,460 --> 00:02:55,710
It changes this to having a very different way of writing it.

39
00:02:56,070 --> 00:03:01,840
So one was the concatenation, and this one is a template that we're using here, which requires this

40
00:03:01,890 --> 00:03:02,610
dollar sign.

41
00:03:03,060 --> 00:03:10,380
So what we can do is we can use this dollar sign and afterwards, whatever the value or the variable

42
00:03:10,380 --> 00:03:13,560
that we want to use is, will be printed here.

43
00:03:14,130 --> 00:03:17,800
So in this case, it's just going to be the result of whatever we had here.

44
00:03:17,820 --> 00:03:20,340
So if we run, this will result in the same.

45
00:03:21,520 --> 00:03:23,750
Type of print statement that we have here.

46
00:03:23,800 --> 00:03:27,640
So I need to run it twice and we are is equal, is false.

47
00:03:28,450 --> 00:03:34,600
So now let's use this a little more, because let's create a another comparison.

48
00:03:34,990 --> 00:03:41,670
Where I'm just going to create is not equal is going to be five, not equal five.

49
00:03:41,680 --> 00:03:45,040
So let's just test if that is true or false.

50
00:03:45,070 --> 00:03:48,250
Of course, it's going to be false because five is equal.

51
00:03:48,250 --> 00:03:48,700
Five.

52
00:03:49,390 --> 00:03:56,710
But if we just print that now and let me put it this again, but now with is not equal.

53
00:03:57,520 --> 00:03:57,910
All right.

54
00:03:57,910 --> 00:04:01,480
So now I'm using is not equal instead of is equal.

55
00:04:01,690 --> 00:04:08,110
And I'm going to comment this line out and I'm going to change the name here as well.

56
00:04:08,120 --> 00:04:10,870
So it's going to be is not equal is.

57
00:04:11,020 --> 00:04:12,850
And then let's see if it's true or false.

58
00:04:13,120 --> 00:04:17,200
And we can see this is not equal, is false because five is equal.

59
00:04:17,200 --> 00:04:20,220
Five, but we are checking if five is not equal five.

60
00:04:20,230 --> 00:04:25,220
So this exclamation mark here says that it should be not equal.

61
00:04:25,360 --> 00:04:30,360
So this year is another way of testing a comparison.

62
00:04:30,700 --> 00:04:33,460
But of course, there are a bunch more that we have here.

63
00:04:33,700 --> 00:04:37,700
So what we can check is, let's say the following.

64
00:04:37,780 --> 00:04:43,450
So instead of creating a new variable for every single one of those comparison operators, let's just

65
00:04:43,450 --> 00:04:45,560
do it in the print line statement directly.

66
00:04:45,850 --> 00:04:46,330
So.

67
00:04:47,680 --> 00:04:58,420
Is greater, so this case is five greater three is going to be and now I'm using something very cool

68
00:04:58,420 --> 00:05:06,370
here because I'm using another pretty cool feature here of Kotlin, where we have the same principle

69
00:05:06,370 --> 00:05:07,210
that we had here.

70
00:05:07,390 --> 00:05:14,620
But now because we don't just have one variable that we want to put into a string, but we want to put

71
00:05:14,620 --> 00:05:19,030
a calculation, so to speak, or in this case, a comparison.

72
00:05:19,460 --> 00:05:24,670
So that whole expression, so to say, and then we need to use these curly brackets.

73
00:05:24,680 --> 00:05:31,450
So we're saying, please run the code within the curly brackets and then print the result in the stead.

74
00:05:31,510 --> 00:05:33,740
So at this spot of our code.

75
00:05:34,450 --> 00:05:35,920
So now if we run this.

76
00:05:37,680 --> 00:05:42,070
We can see that it says is five crater three is true.

77
00:05:42,210 --> 00:05:46,100
Well, of course it's true because five is a greater number than three years.

78
00:05:46,800 --> 00:05:50,190
But now let's say we check the same thing with a minus five.

79
00:05:50,700 --> 00:05:56,040
If that is greater than three, then it should be false and that we are just false.

80
00:05:56,070 --> 00:05:59,320
Of course, I didn't add the minus here in the print statement.

81
00:05:59,700 --> 00:06:00,000
All right.

82
00:06:00,000 --> 00:06:01,980
But get the gist of it now.

83
00:06:02,390 --> 00:06:06,090
Of course, we can do the same with some other print statements here.

84
00:06:06,090 --> 00:06:13,290
So print 11 is five, lower equal three.

85
00:06:14,520 --> 00:06:18,120
And then please try to do the expression in here.

86
00:06:18,390 --> 00:06:20,940
So try it yourself before I will show you how to.

87
00:06:22,320 --> 00:06:30,690
All right, so the expression starts with a curly bracket and then we say five less than equal three.

88
00:06:31,810 --> 00:06:38,560
All right, so this is the expression now let's see what we get as a result here and we can see is five

89
00:06:38,560 --> 00:06:43,490
lower equal three it says false because five is a greater number than three.

90
00:06:43,690 --> 00:06:45,580
So the whole expression.

91
00:06:46,480 --> 00:06:51,170
Ends up being false, and that's what we get as the print statement here.

92
00:06:51,760 --> 00:06:56,620
So this concept that we use here is called string interpolation.

93
00:06:56,860 --> 00:06:57,250
All right.

94
00:06:57,260 --> 00:07:05,290
So just so you have seen this keyword, of course, you can now go ahead and do the same with the other

95
00:07:05,620 --> 00:07:08,590
comparison operators that we've seen there at the top.

96
00:07:08,620 --> 00:07:20,140
So instead, we can use Krater equal and here is higher or greater equal three.

97
00:07:20,740 --> 00:07:21,550
And then.

98
00:07:22,740 --> 00:07:24,000
We saw the other one, right?

99
00:07:24,420 --> 00:07:25,140
I actually.

100
00:07:27,420 --> 00:07:28,020
Is.

101
00:07:28,950 --> 00:07:29,550
Les.

102
00:07:30,560 --> 00:07:31,040
Three.

103
00:07:32,530 --> 00:07:33,670
And I let's to run this.

104
00:07:35,370 --> 00:07:38,630
So now we have all of our results here.

105
00:07:40,670 --> 00:07:43,900
Is not equal this false or is minus five?

106
00:07:43,940 --> 00:07:49,880
Less than three, it's true, of course, because a negative value is going to be less than a positive

107
00:07:49,880 --> 00:07:57,080
value than we have is lower or five lower equal three is false and is five greater equal.

108
00:07:57,080 --> 00:07:58,100
Three is true.

109
00:07:58,710 --> 00:08:04,580
Of course, we can also set a five in there just to see if this is still going to work.

110
00:08:06,190 --> 00:08:09,830
And once we run it, we can see is five greater equal?

111
00:08:09,850 --> 00:08:13,340
Five is also true because five is equal, five.

112
00:08:13,360 --> 00:08:15,490
That's why this equation is correct.

113
00:08:15,700 --> 00:08:19,880
So this greater equal is accepting both.

114
00:08:20,080 --> 00:08:26,140
So it's going to return true if the left value is greater than the right value or if they are equal.

115
00:08:26,920 --> 00:08:27,250
All right.

116
00:08:27,250 --> 00:08:29,140
So that's it for assignment operators.

117
00:08:29,320 --> 00:08:33,850
And the next video, we are going to check out increment and decrement operators.

118
00:08:33,880 --> 00:08:34,690
So see their.

