1 00:00:00,480 --> 00:00:02,840 Hello and welcome to this lecture. 2 00:00:02,940 --> 00:00:12,240 In this picture are be covering in some comparison operators that can be used with the Ruby programming 3 00:00:12,420 --> 00:00:14,110 language. 4 00:00:14,200 --> 00:00:18,990 I've got a table here of some comparison operators. 5 00:00:19,080 --> 00:00:22,500 I'm just going to quickly run through them with you. 6 00:00:22,500 --> 00:00:30,040 The first on the list here is the sequence two and the symbol for that is the double. 7 00:00:30,090 --> 00:00:40,320 Because to see if you want to compare values you see Frank they have a variable here called X which 8 00:00:40,320 --> 00:00:45,750 it's got the value of four and a variable y which is got a value of six. 9 00:00:45,840 --> 00:00:49,150 So you can do comparison between the two values. 10 00:00:49,260 --> 00:00:53,690 So I can see X double equals to men. 11 00:00:53,760 --> 00:00:55,120 You are comparing. 12 00:00:55,350 --> 00:00:58,550 Here's I think you've got just a single equals two. 13 00:00:58,710 --> 00:01:05,920 It means you are signing in value that is here is a single IT WAS TO is used to assign values while 14 00:01:05,930 --> 00:01:08,420 double is used to compare. 15 00:01:08,670 --> 00:01:14,990 So what I'm saying is that is X equals to Y. 16 00:01:15,000 --> 00:01:21,190 The answer is force is for us on the fourth value because X is not equal to Y. 17 00:01:21,480 --> 00:01:24,030 Here will be not equal sign. 18 00:01:24,070 --> 00:01:32,380 And this is the symbol so X has a value or for y value of 6. 19 00:01:32,700 --> 00:01:39,650 And here with same why is not equal to x which is true. 20 00:01:39,700 --> 00:01:43,320 Can wait 6 an X is 4. 21 00:01:43,470 --> 00:01:45,600 We've got another comparison. 22 00:01:45,710 --> 00:01:47,740 Nothing's greater. 23 00:01:48,900 --> 00:01:50,040 So here we go. 24 00:01:50,040 --> 00:01:59,400 Variable x which is 4 and a wide variable which is 6 is saying is X greater done Y. 25 00:01:59,520 --> 00:02:03,540 No it is not science's but it will return force of course. 26 00:02:03,570 --> 00:02:05,740 X is for and y. 27 00:02:05,800 --> 00:02:17,340 If the next We've got the less than comparison so X is for y is x is x leston Y. 28 00:02:17,640 --> 00:02:18,800 Yes. 29 00:02:18,840 --> 00:02:20,730 Well evaluate to be true. 30 00:02:20,730 --> 00:02:22,550 Of course it is for and why. 31 00:02:22,590 --> 00:02:23,410 6. 32 00:02:23,670 --> 00:02:27,200 And this is the symbol for less than side. 33 00:02:27,720 --> 00:02:31,710 So you can also have the greater than or equal to. 34 00:02:32,070 --> 00:02:37,700 Which means in value your comparing was either be greater than or equal to. 35 00:02:37,950 --> 00:02:39,030 For example here. 36 00:02:39,140 --> 00:02:44,720 Value x 4 and Y variable is 6 is the expression. 37 00:02:44,730 --> 00:02:45,120 Here is. 38 00:02:45,120 --> 00:02:50,890 That is why is greater than or equal to x. 39 00:02:51,210 --> 00:02:59,980 That is true call y his 6 X is false or why he is greater than x so he will evaluate to be true. 40 00:03:00,210 --> 00:03:05,410 On the other spectrum we've got less than not equal to x is 4. 41 00:03:05,460 --> 00:03:12,970 Why is 6 the expression here in X is less than or equal as to why. 42 00:03:12,990 --> 00:03:17,780 Which is true cause X is for y is sixth. 43 00:03:17,820 --> 00:03:21,840 So let's open up our interactive Ruby. 44 00:03:21,900 --> 00:03:24,980 Play around with some of these values. 45 00:03:24,990 --> 00:03:28,370 The first thing I want to do is find a variable. 46 00:03:28,410 --> 00:03:30,540 I am going to define a variable x. 47 00:03:30,570 --> 00:03:37,340 I am going to set that to 4 give you the value for our create and then a variable y. 48 00:03:37,660 --> 00:03:40,400 I'll give you the value of fix. 49 00:03:40,590 --> 00:03:43,010 So what variables have been created. 50 00:03:43,020 --> 00:03:48,090 You can really use them over and over again unless you change the value. 51 00:03:48,480 --> 00:03:57,140 So the first comparison I'm going to do is I want to check if one variable is equal to the other. 52 00:03:57,140 --> 00:03:59,470 And you do that with a double equals to sign. 53 00:03:59,670 --> 00:04:11,730 So I want to see x is equal to you use a double equates to why X is 4 and why it is 6 so I expect this 54 00:04:11,730 --> 00:04:14,460 to return in value or force. 55 00:04:14,520 --> 00:04:15,280 So there you go. 56 00:04:15,300 --> 00:04:17,340 It has returned force. 57 00:04:17,450 --> 00:04:28,080 Also I can check if a value is not equal to something so I can see why no y value of y is 6. 58 00:04:28,350 --> 00:04:35,330 So I can see why it is not equal to x. 59 00:04:35,580 --> 00:04:40,660 Okay call y is fix an X is forswore. 60 00:04:40,740 --> 00:04:46,520 This also we evaluate to true you are because the expression is right. 61 00:04:46,520 --> 00:04:46,940 Y. 62 00:04:46,970 --> 00:04:54,130 He is 6 X's for less two is greater than comparison. 63 00:04:54,210 --> 00:04:59,240 So if I see x is x greater than y. 64 00:04:59,610 --> 00:04:59,950 No. 65 00:05:00,420 --> 00:05:12,820 This return force is why greater than x this we're in this will return true because why is greater then 66 00:05:13,670 --> 00:05:14,150 right. 67 00:05:14,190 --> 00:05:17,760 So little less than is X 68 00:05:20,490 --> 00:05:26,160 less than Y that we valued to be true. 69 00:05:26,670 --> 00:05:27,200 Okay. 70 00:05:27,270 --> 00:05:31,200 There's too great a dan or even Also too. 71 00:05:31,290 --> 00:05:45,530 So here's why greater than an equals to X that we again value it to be true or Y is greater than x. 72 00:05:46,260 --> 00:05:49,640 We'll do one more we'll do a less down this time. 73 00:05:49,710 --> 00:06:04,510 So we say is X less than or equal as to why that's valid too true because X is less than Y. 74 00:06:04,740 --> 00:06:13,140 So these are some basic comparison operators that can be used in the Ruby programming language. 75 00:06:13,380 --> 00:06:15,880 Many thanks for watching and bye for now.