Hello and welcome to this lecture.
In this lecture I'll be talking to you about strength.
What are strengths in Ruby and in most other programming languages.
Strings are a sequence of characters or a group of letters strong together so you can look at a string
or you can think of this string as printed letters strung together on a banner.
Also for the programming language to know that you are referring to a string all strings you must enclose
them in quotes.
So strings must be enclosed in quotes.
You can either use single chords or you can use the quarter but you can't mix them.
You can start with a single and end up with a double and vice versa.
So some examples of strings include hello world chocolates you name it.
So you can see they all enclose in quotes so you can add a single or double quotes.
There's a lot you can do with strings or let's play around with some of the things you can do with strings.
Some will open interactive UBE Ruby angle and go to start our program click on my ruby folder and then
click interactive Ruby.
If you are on a Mac you can just type in.
Hi.
Are a B in your terminal.
I feel on the Linux type in harrowby in your shell and that should give you access to the interactive
roub you can do all sorts of things to string So let's start by multiplying a string.
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
name of the drink.
I am going to and typing.
Chocolate.
Chocolate K and then a multiplier that by 5 so bizarre.
Well I say I want the word chocolate displayed five times on the screen.
A price ponytail you can see is displayed it you can see there or like chucked together.
There's no room for each of them to breathe.
So the reason being is that I didn't leave a space between the quotes and the first letter of chocolate.
So let's try that again.
So who do puts followed by quotes and then do a space this time before the chocolate.
Okay.
See here.
Well.
And then put the other quotes.
Then this time the multiplication times 5 enter.
You can see there are spaces so they can breathe now.
So is always important.
Bear that in mind if you want gaps or spaces of paper between your strings and you when you his enquires
make show you leave a gap.
Mike have done here.
Now you get them more jammed together like they have.
Like I've done here.
Alright so that's one way of using strings.
Ken what if I had them together.
He can also add strings together so I can add two string through the first ring.
B c Hello.
And then I add a plus fine because I'm adding two strings together because I want them and one there
to be some space between the string so I'm going to use empty quotes so to empty quotes which means
it will create some space and then I use the plus side to add the other shrink and I lost time being
bought a presenter.
That should give me hellowallet a go.
You can see the quotes I've used here.
This code is created the space in between.
So that's how you add strings together in some programming language is called concatenation.
When you add strings together.
Another thing you can do with strings.
You can find out the length of this string.
So for example typee Puts A C U demming.
Dot let
a press enter.
That will give me tells me that you there me is 7 characters.
All right so you got one two three four five.
He counts the space as a character.
I left this space here a leftist base here so hennessey's got 7.
So take note here when you include the space.
It also counts is where any spaces between big quotes are also regarded as character.
They are counted as well.
Let's try a few more.
Side type pain points are now do.
Hello.
In lower case.
So if I want to convert that to uppercase I do a dot.
And do you.
P case.
And that will come about.
Or that to upper case.
Okay if I want to do a reverse do puts an end to b.
Hello
fi I want to convert that to lower and do a down case.
Pin down
enter and that converts it to Louis.
If you enclose pull strings around numbers programming language also treat it as the strengths if for
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
two to the power of six.
So give me 2 6 types because he's treated as a string.
So by percentile.
You can see that is giving me 2 6 times so it treats it has strings to be careful what for for that
as well.
I'll try one more thing to say for example you are trying to put something that was caught up Prospero
freeze it say for example if I see you typing you
are awesome.
So you need to use the escape.
I explain this in a minute.
You are awesome
for watching this video.
Okay.
And uh Precentor.
Ms.
Casey you are awesome misdoubt the prossed fee where you are using a process to fees you mossies a backslaps
and the backslap physically is an escape evil escape me character without doubt you wouldn't be able
to display detectors correctly.
So let me try that again.
So do puts men then two quotes.
I'll see you back.
That's the apostrophe.
You are awesome.
Press Enter.
Okay now you are awesome.
Without the backslaps I won't get the apostrophe here will not work.
So bear in mind.
Because were you using quotes and using that prossed a fee as well within the string.
You must choose an escape for the apostrophe to show up in the output.
So this so much you can do with.
So I encourage you to practice on the ruby website you can see some examples there and just play around
with what with the strings.
So that's it for this lecture.
Many thanks for watching and bye for now.