Hi, in this video, we're going to be talking about strings. So one thing to note is that all strings in golang are mutable, which means that you can change the value of strings again and again and again. So to define a string, you simply do our empty string. And you can do and what is equal to my name. It's as simple as that. For initialization and one line, you can also do this and one, colon equals to my name, and it's still gonna work.
So to check the mute to check the mutability of the string, I can simply do this, I can update it. So we got an error over here. That is because the colon equal to sign is only used for declaration. It's not useful assignment. For assignment we only have a single equal to, so once you've declared a variable, a memory is allocated for this variable. You don't need to Initial exit anymore, you can only change the value after that if you were able to update the variable.
So, with strings we have, we also have a lot of string functions. So let's say we got two variables called m m one and m two. And we can do, yeah. So, if you want to check em two contains Mo, no not. Let's see if we can do that. So you can include a strings.
Dork contains m one, m two. And it's gonna print out a boolean value true. That is because m two is contained in m one. This is a really useful function to find substrings in, in a larger string, and there are a lot of functions defined on a string. So you can do a string dot replace all so I can replace all of the M's in my M one Then, nope. Let's see what happens.
And I'm gonna go out and do crazy not using that anymore. Huh, look at this. So all of the M's were replaced by nodes by using the strings dot replace all. And there are different functions like we can split a string, according to its delimiters. And what's stripping essentially does is you specify a delimiter. And what happens is if you want to split a string by, let's say, space, so mining contains one space, so this is going to be one object, this is going to be a second object, and it's going to form an area of those.
So strings are split, we simply enter a string and we enter the delimiter. And it's going to return an array activists. So the string is Emma, the delimiter here is space. So let's see what happens. Added was returned. So in this video we learned a lot about strings, and how to function with strings how to concatenate strings with strings.
And concatenation is actually really simple. So, you simply do m one plus m two m one plus into that. And so any doubt with the strings function, you can, you can type just stripe strings, dot and you can read up the description of everything. And you can do a Ctrl spacebar, and then you can do enter to enter that function in this. Thank you