1 00:00:00,540 --> 00:00:03,770 Hello and welcome to this leg shot in this lecture. 2 00:00:03,810 --> 00:00:09,340 I'll be talking to you about variables in the Ruby programming language. 3 00:00:09,420 --> 00:00:11,700 What is a variable variable. 4 00:00:11,850 --> 00:00:16,770 Basically is a memory location. 5 00:00:17,020 --> 00:00:27,170 Irish place that holds any day tiny piece of data that can be use by a program or any program. 6 00:00:28,190 --> 00:00:40,380 It variable is also a name that Ruby associates with a particular object variable names should be lower 7 00:00:40,420 --> 00:00:48,600 case whereby you have variable names that contains two word is best to use an underscore to separate 8 00:00:48,750 --> 00:00:49,500 the words. 9 00:00:49,500 --> 00:00:53,200 For example he may have a variable called Order mount. 10 00:00:53,210 --> 00:00:56,350 Bessie is an on the score to separate the words. 11 00:00:56,700 --> 00:01:00,240 Unless you intend to give it it's just one word. 12 00:01:00,240 --> 00:01:07,980 In that case you can call it total for example variables in Ruby can contain any data types so you can 13 00:01:07,980 --> 00:01:10,950 have a string or an integer. 14 00:01:10,950 --> 00:01:18,420 Also when you name your variable give them common sense names that reflect what the variable doors or 15 00:01:18,420 --> 00:01:22,060 what day to day hold or store. 16 00:01:22,230 --> 00:01:29,490 You can not use reserved names in the Ruby programming language for variable names for example you can 17 00:01:29,520 --> 00:01:33,000 call it variable class method on module. 18 00:01:33,000 --> 00:01:39,120 These are all reserved words that are already used in the Ruby programming language. 19 00:01:39,120 --> 00:01:41,480 These are just a few examples. 20 00:01:41,490 --> 00:01:50,700 If you want a detailed example Reserve word you have to reference the ruby documentation variables in 21 00:01:50,700 --> 00:01:58,140 themselves and not object by references to objects in the Ruby programming language before you can use 22 00:01:58,140 --> 00:01:58,780 a variable. 23 00:01:58,800 --> 00:02:07,060 You must assign or give you the value variable that hasn't got good value is referred to as on defined. 24 00:02:07,560 --> 00:02:16,270 What is an assignment and assignment basically is some operator that is used to give variables in value. 25 00:02:16,840 --> 00:02:17,690 Okay. 26 00:02:17,700 --> 00:02:24,530 Usually you identify that with the symbol the symbol for an assignment operator is equal to say. 27 00:02:24,870 --> 00:02:28,430 So let's take a look at a couple of examples. 28 00:02:28,470 --> 00:02:30,720 First here I've got a variable called X.. 29 00:02:30,780 --> 00:02:38,350 We've signed it off 7 0 got another variable cuong greeting me assigned it to a value of Hello. 30 00:02:38,490 --> 00:02:42,170 So let's say you use the assignment operator. 31 00:02:42,330 --> 00:02:44,690 I've got my interactive Ruby open. 32 00:02:44,700 --> 00:02:49,750 If you on a Windows This is located in your ruby fault in our program. 33 00:02:50,000 --> 00:02:57,420 If you are on here Linux or a Mac just type in our being in your temin or shell that should give you 34 00:02:57,480 --> 00:02:58,180 access. 35 00:02:58,230 --> 00:02:59,800 Let's create some variables. 36 00:02:59,830 --> 00:03:07,630 And when I create a variable context and give it a value of 7 I create on a pillow variable call. 37 00:03:07,660 --> 00:03:25,950 Why I give this value or if I create another one chord set and then give this the value would be x plus 38 00:03:27,320 --> 00:03:31,040 why that give 15. 39 00:03:33,170 --> 00:03:37,570 So if I type in there is to output 15. 40 00:03:37,670 --> 00:03:44,390 You can also change the value of a variable once you've assigned to value for example I can come here 41 00:03:44,510 --> 00:03:50,490 and change decks to ecorse to instead of being 7. 42 00:03:50,510 --> 00:03:53,710 I can make x 15. 43 00:03:54,290 --> 00:04:05,080 So now I can see the Z course to X class Y. 44 00:04:05,120 --> 00:04:07,530 That will no longer give me 15. 45 00:04:07,550 --> 00:04:08,690 Now what is it all value. 46 00:04:08,690 --> 00:04:16,730 This should now change and give me twenty three so if I type in there the new value for Z is 23 so you 47 00:04:16,730 --> 00:04:20,180 can always change the value once you've given a variable name. 48 00:04:20,290 --> 00:04:21,880 So let's create another variable. 49 00:04:21,880 --> 00:04:24,900 Core is greeting. 50 00:04:25,440 --> 00:04:33,190 Can I just give you a valley of say hello. 51 00:04:38,520 --> 00:04:48,000 So if I want a reference that I just typing puts followed by the word greeting and that does give me 52 00:04:48,060 --> 00:04:49,080 hello. 53 00:04:49,770 --> 00:04:57,340 So if I wanted to change the value of that greeting I just can't taiping greet in ecorse too. 54 00:05:00,900 --> 00:05:04,790 How are you. 55 00:05:07,530 --> 00:05:08,540 Okay. 56 00:05:08,850 --> 00:05:16,160 Now if I'm typing greeting I should get how are you. 57 00:05:16,800 --> 00:05:23,750 So why should you assign values you can always change them so feel free to experiment creating. 58 00:05:23,900 --> 00:05:26,220 Boer's a sign of a bad to that. 59 00:05:26,310 --> 00:05:28,110 So that's it for this lecture. 60 00:05:28,140 --> 00:05:29,230 On their reports. 61 00:05:29,280 --> 00:05:30,540 Many thanks for watching. 62 00:05:30,540 --> 00:05:31,430 Bye for now.