0
What was the use of char function in Kotlin?
How do we use it and for what?
2 Antworten
+ 1
Just to add on to what Jay Matthews said , you're using the word function wrong. It's a datatype and a primitive one at that.
You use a char everytime you code REGARDLESS of language because they are the characters that make up Strings. In fact, in the C language, there are no strings, you would have to make an array of chars (iirc) to get close to a string.
For example, in my code below, I had made a map that contains the datatypes Char, and Int. If I try to use String, it will throw an error, because I am only using one letter at a type. You can modify my code to see what happens. https://code.sololearn.com/ci8SAvHvmYml/?ref=app
0
Char is the basic building block of String. It is a basic type used to represent a character literal. e.g val firstVowel = 'a'