1 00:00:00,690 --> 00:00:02,910 Hello and welcome to this lecture. 2 00:00:02,970 --> 00:00:07,520 In this lecture I'll be talking to you about strength. 3 00:00:07,680 --> 00:00:13,690 What are strengths in Ruby and in most other programming languages. 4 00:00:13,890 --> 00:00:26,970 Strings are a sequence of characters or a group of letters strong together so you can look at a string 5 00:00:26,970 --> 00:00:35,140 or you can think of this string as printed letters strung together on a banner. 6 00:00:35,140 --> 00:00:45,690 Also for the programming language to know that you are referring to a string all strings you must enclose 7 00:00:45,690 --> 00:00:48,400 them in quotes. 8 00:00:48,710 --> 00:00:51,800 So strings must be enclosed in quotes. 9 00:00:51,810 --> 00:00:57,210 You can either use single chords or you can use the quarter but you can't mix them. 10 00:00:57,210 --> 00:01:01,400 You can start with a single and end up with a double and vice versa. 11 00:01:01,620 --> 00:01:07,850 So some examples of strings include hello world chocolates you name it. 12 00:01:08,040 --> 00:01:13,760 So you can see they all enclose in quotes so you can add a single or double quotes. 13 00:01:13,800 --> 00:01:20,520 There's a lot you can do with strings or let's play around with some of the things you can do with strings. 14 00:01:20,560 --> 00:01:28,900 Some will open interactive UBE Ruby angle and go to start our program click on my ruby folder and then 15 00:01:28,920 --> 00:01:31,130 click interactive Ruby. 16 00:01:31,200 --> 00:01:35,020 If you are on a Mac you can just type in. 17 00:01:35,040 --> 00:01:35,320 Hi. 18 00:01:35,340 --> 00:01:37,140 Are a B in your terminal. 19 00:01:37,290 --> 00:01:44,580 I feel on the Linux type in harrowby in your shell and that should give you access to the interactive 20 00:01:44,760 --> 00:01:53,420 roub you can do all sorts of things to string So let's start by multiplying a string. 21 00:01:53,700 --> 00:02:02,040 So I'm going to type P inputs if I don't use puts it doesn't remove the quotes and puts type in the 22 00:02:02,040 --> 00:02:03,690 name of the drink. 23 00:02:03,770 --> 00:02:05,060 I am going to and typing. 24 00:02:05,080 --> 00:02:07,370 Chocolate. 25 00:02:08,120 --> 00:02:10,490 Chocolate. 26 00:02:11,550 --> 00:02:17,390 Chocolate K and then a multiplier that by 5 so bizarre. 27 00:02:17,400 --> 00:02:23,490 Well I say I want the word chocolate displayed five times on the screen. 28 00:02:23,700 --> 00:02:30,200 A price ponytail you can see is displayed it you can see there or like chucked together. 29 00:02:30,280 --> 00:02:32,900 There's no room for each of them to breathe. 30 00:02:32,910 --> 00:02:40,430 So the reason being is that I didn't leave a space between the quotes and the first letter of chocolate. 31 00:02:40,430 --> 00:02:41,800 So let's try that again. 32 00:02:42,070 --> 00:02:52,410 So who do puts followed by quotes and then do a space this time before the chocolate. 33 00:02:52,920 --> 00:02:53,490 Okay. 34 00:02:53,490 --> 00:02:54,980 See here. 35 00:02:55,780 --> 00:02:57,140 Well. 36 00:02:59,400 --> 00:03:02,900 And then put the other quotes. 37 00:03:03,150 --> 00:03:08,290 Then this time the multiplication times 5 enter. 38 00:03:08,430 --> 00:03:12,220 You can see there are spaces so they can breathe now. 39 00:03:12,240 --> 00:03:13,590 So is always important. 40 00:03:13,590 --> 00:03:20,460 Bear that in mind if you want gaps or spaces of paper between your strings and you when you his enquires 41 00:03:20,520 --> 00:03:22,320 make show you leave a gap. 42 00:03:22,320 --> 00:03:23,250 Mike have done here. 43 00:03:23,280 --> 00:03:27,030 Now you get them more jammed together like they have. 44 00:03:27,040 --> 00:03:28,400 Like I've done here. 45 00:03:28,600 --> 00:03:31,650 Alright so that's one way of using strings. 46 00:03:31,680 --> 00:03:34,010 Ken what if I had them together. 47 00:03:34,140 --> 00:03:42,100 He can also add strings together so I can add two string through the first ring. 48 00:03:42,120 --> 00:03:49,660 B c Hello. 49 00:03:52,830 --> 00:04:00,040 And then I add a plus fine because I'm adding two strings together because I want them and one there 50 00:04:00,060 --> 00:04:06,630 to be some space between the string so I'm going to use empty quotes so to empty quotes which means 51 00:04:06,660 --> 00:04:15,830 it will create some space and then I use the plus side to add the other shrink and I lost time being 52 00:04:15,970 --> 00:04:19,900 bought a presenter. 53 00:04:19,920 --> 00:04:22,650 That should give me hellowallet a go. 54 00:04:22,650 --> 00:04:25,260 You can see the quotes I've used here. 55 00:04:25,260 --> 00:04:28,190 This code is created the space in between. 56 00:04:28,470 --> 00:04:36,120 So that's how you add strings together in some programming language is called concatenation. 57 00:04:36,120 --> 00:04:39,490 When you add strings together. 58 00:04:39,860 --> 00:04:41,550 Another thing you can do with strings. 59 00:04:41,550 --> 00:04:44,870 You can find out the length of this string. 60 00:04:45,130 --> 00:04:53,660 So for example typee Puts A C U demming. 61 00:04:57,630 --> 00:04:58,960 Dot let 62 00:05:02,490 --> 00:05:04,000 a press enter. 63 00:05:04,080 --> 00:05:09,110 That will give me tells me that you there me is 7 characters. 64 00:05:09,200 --> 00:05:13,670 All right so you got one two three four five. 65 00:05:13,980 --> 00:05:17,130 He counts the space as a character. 66 00:05:17,270 --> 00:05:21,860 I left this space here a leftist base here so hennessey's got 7. 67 00:05:21,960 --> 00:05:25,800 So take note here when you include the space. 68 00:05:25,800 --> 00:05:32,350 It also counts is where any spaces between big quotes are also regarded as character. 69 00:05:32,370 --> 00:05:34,730 They are counted as well. 70 00:05:35,610 --> 00:05:37,180 Let's try a few more. 71 00:05:37,180 --> 00:05:42,780 Side type pain points are now do. 72 00:05:44,180 --> 00:05:45,030 Hello. 73 00:05:45,040 --> 00:05:47,030 In lower case. 74 00:05:47,030 --> 00:05:51,510 So if I want to convert that to uppercase I do a dot. 75 00:05:51,900 --> 00:05:52,780 And do you. 76 00:05:52,790 --> 00:05:54,530 P case. 77 00:05:54,810 --> 00:05:56,140 And that will come about. 78 00:05:56,190 --> 00:05:58,600 Or that to upper case. 79 00:05:59,100 --> 00:06:05,750 Okay if I want to do a reverse do puts an end to b. 80 00:06:06,260 --> 00:06:06,800 Hello 81 00:06:09,510 --> 00:06:17,780 fi I want to convert that to lower and do a down case. 82 00:06:18,270 --> 00:06:19,020 Pin down 83 00:06:21,710 --> 00:06:24,710 enter and that converts it to Louis. 84 00:06:24,900 --> 00:06:32,250 If you enclose pull strings around numbers programming language also treat it as the strengths if for 85 00:06:32,250 --> 00:06:51,390 example if I do puts Do as I do quotes and typing to do space time 5 or 6 time it's a trait that has 86 00:06:51,450 --> 00:06:53,210 two to the power of six. 87 00:06:53,220 --> 00:06:58,410 So give me 2 6 types because he's treated as a string. 88 00:06:58,860 --> 00:06:59,820 So by percentile. 89 00:06:59,820 --> 00:07:07,200 You can see that is giving me 2 6 times so it treats it has strings to be careful what for for that 90 00:07:07,290 --> 00:07:08,140 as well. 91 00:07:08,520 --> 00:07:15,950 I'll try one more thing to say for example you are trying to put something that was caught up Prospero 92 00:07:15,960 --> 00:07:22,410 freeze it say for example if I see you typing you 93 00:07:24,960 --> 00:07:26,310 are awesome. 94 00:07:26,830 --> 00:07:28,980 So you need to use the escape. 95 00:07:29,070 --> 00:07:30,210 I explain this in a minute. 96 00:07:30,210 --> 00:07:33,420 You are awesome 97 00:07:36,750 --> 00:07:38,860 for watching this video. 98 00:07:42,140 --> 00:07:42,960 Okay. 99 00:07:43,090 --> 00:07:44,990 And uh Precentor. 100 00:07:45,680 --> 00:07:46,720 Ms. 101 00:07:48,420 --> 00:07:58,590 Casey you are awesome misdoubt the prossed fee where you are using a process to fees you mossies a backslaps 102 00:07:58,590 --> 00:08:05,280 and the backslap physically is an escape evil escape me character without doubt you wouldn't be able 103 00:08:05,280 --> 00:08:07,110 to display detectors correctly. 104 00:08:07,110 --> 00:08:08,590 So let me try that again. 105 00:08:08,590 --> 00:08:14,230 So do puts men then two quotes. 106 00:08:14,720 --> 00:08:17,440 I'll see you back. 107 00:08:17,460 --> 00:08:20,480 That's the apostrophe. 108 00:08:20,880 --> 00:08:23,800 You are awesome. 109 00:08:27,720 --> 00:08:28,740 Press Enter. 110 00:08:29,110 --> 00:08:30,940 Okay now you are awesome. 111 00:08:31,110 --> 00:08:36,680 Without the backslaps I won't get the apostrophe here will not work. 112 00:08:36,690 --> 00:08:38,660 So bear in mind. 113 00:08:38,690 --> 00:08:43,440 Because were you using quotes and using that prossed a fee as well within the string. 114 00:08:43,440 --> 00:08:49,020 You must choose an escape for the apostrophe to show up in the output. 115 00:08:49,140 --> 00:08:51,320 So this so much you can do with. 116 00:08:51,330 --> 00:08:58,740 So I encourage you to practice on the ruby website you can see some examples there and just play around 117 00:08:58,740 --> 00:09:00,540 with what with the strings. 118 00:09:00,660 --> 00:09:02,310 So that's it for this lecture. 119 00:09:02,330 --> 00:09:05,210 Many thanks for watching and bye for now.