Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

whats name of this ' ' mark in kotlin [duplicate]

Tags:

kotlin

I am reading user input using scanner class, when I write code then there is ' ' marks appears around .in, i try to search about it but not found what its name and use of it can you guys tell me more about this.

my code

fun main(args:Array<String>)
{
    var input = Scanner(System.'in')

    println("Enter input : ")

    var userInput = input.nextInt()

    println("You entered : $userInput")
}

why code only works when I add '' marks around in otherwise it not work. I got error message

Kotlin: Expecting an element
like image 544
dev_swat Avatar asked Sep 05 '25 13:09

dev_swat


1 Answers

in is a reserved keyword in Kotlin, so you need to escape it with backticks (example: `in` ) in order for it to work. Single quotes (example: 'in') are used for character literals, not string literals, so backticks are required.

like image 194
Eric Bachhuber Avatar answered Sep 08 '25 21:09

Eric Bachhuber