Learning Kotlin: The awesome that is the backtick

Submitted by Robert MacLean on Thu, 07/05/2018 - 09:00
**More Information** * This is the 14th post in a multipart series. If you want to read more, see our [series index](/learning-kotlin-introduction) The backtick in Kotlin is meant to allow Kotlin to use [keywords](https://kotlinlang.org/docs/reference/keyword-reference.html) or, since Kotlin is meant to interop with Java, allow Kotlin to call Java functions that might conflict with Kotlin; for example, this won't work val class = "school" println(class) If we wrap `class` in backticks (as it is a keyword) then it works just fine: val `class` = "school" println(`class`) This is nice... however it can be used for function names too, for example with tests we might use underscores to make the name verbose: fun should_return_true_for_values_of_one() { however... fun `should return true for values of one`() { Yes! That is a function name with REAL SPACES in it! AWESOME!