4

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
dev_swat
  • 1,264
  • 1
  • 12
  • 26

1 Answers1

10

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.

Eric Bachhuber
  • 3,872
  • 2
  • 19
  • 26