Hello and welcome to the Golang programming language course.
In the previous session, we talked about three imperfect in history and in this, we want to talk about
the other extreme concept.
Is split a string in go blank?
In GO districts, you are allowed to split a string into a slice with the help of following functions.
These functions are defined under a strings package, so you have to import the strings package in your
program for accessing these functions.
First, this split.
This function splits a string into all solid string separated by the Gibbons separator and returns a
slice which contains these substances.
Now you can see the scene techs.
Here, SDR is the extreme and SAP is the separator.
If SDR does not contain the given sit and sip is not empty, then it will return a slice of black swan,
which contain only SDR or if the SAP is A. Then it will split after each UTF eight sequence, or if
both SDR and SIP are empty, then it will return an entire slice.
Now let's go to the school for a grant to illustrate how to split a string.
First, creating an initializing the three extreme variables is still wrong.
Calling equals CET value very calm.
Comma to the comma, go programming, comma language, go to the next line and define another variable
like SDR to call an equal set value.
My name is Robert and go to the next line is two or three equals cet value.
I am.
A GO program is
now displaying Valley three is before using a split function.
AFP S.T.A.R. colour is still warm.
If this is your tool, colour sit still too.
And if P is to your tree colour and asset value, there is still a tree.
Okay, now is pleading to give you this string using split function.
For the example, S2 is first is turning into all substring separated by the comma separator and returns
this guide.
It contains some strings defining variable light result while calling equals the strings package and
call split function first set variable name in this case SDR one and set separator in this case, comma
for the other variables.
Do these resolved?
Oh, Colin decodes the strings package that is fleet.
And that SDR to variable and set a space for this case, go to the next line and define another variable
result.
Three Colin equals strength the split function there are three and for this case, said exclamation
mark as the creator now displaying the result variables for the example, for the resolved one, peacefully
value and type of value will go to the next line.
If Earth back has less and resolved one time per cent to offer case back T please on one per cent,
the bank is less and said resolved long and resolved one.
Now its rate result one is a slice and disbelief value of it by the range for a loop.
For the example, four underscore common set of areas ED like value column equals wrench in result won't
go to the body a statement and said if the value.
And go out of the follow up and display the other variables, for the example, FP result to color resolved
to be resolved.
Three, Colin and said result.
Three.
OK.
Defoliant, they quote, save the project and execute the program.
Now we can see that output for the first variable defined the common character as a separate or to use
the split function and drop is a slice of the string as the return value inside the reasons why and
then display the value and type of the result variable and use the range POLU to iterate.
The result is a nice value.
We also do this for the second and third variables in third variables.
It does not contain the given separator.
Then it returns lines of legs, one which contain only CIF variable value.
In order not to prolong the time of decision, we will finish sheet and we will continue the content
in the next session.
Goodbye.