What was the use of char function in Kotlin? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What was the use of char function in Kotlin?

How do we use it and for what?

7th Jun 2022, 5:08 AM
Mishthi mehrotra
Mishthi mehrotra - avatar
2 Answers
+ 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
7th Jun 2022, 9:49 AM
Justice
Justice - avatar
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'
12th Jun 2022, 3:32 AM
Mírian Fonkam
Mírian Fonkam - avatar