package X import A import B.* fun main(args: Array) { val ` + "with spaces" + ` = "hello" val multiline = """1 2""" StringBuilder().apply { append(multiline) } val unsigned = 0x00UL + 123u + 76.54 } /* */ fun nullable(nullable: String?): Int = nullable?.length ?: 0 fun nullable2(nullable: String?): Int = nullable?.length ?: run { 1 + 2 } val rawStringWithQuotes = """ Hello "example" ${1 + 2} And now { Just the braces } Escapes here don't work so this is just text \t \n \u1234 $ \$ """ fun returnsSomething(): Int { return "".length } fun returnsSomethingElse(): Int = "\\\n".length val character = '"' val escapedCharacter = '\"' // escaping a double quote character inside a character is optional val stringWithSingleQuote = "'" typealias MySecretAlias = (A, B) -> Unit val impl : MySecretAlias = { a, _ -> Unit } fun someOperators(a: Int, b: Int) { var c : Int = 123 println("This is an example a = $a and the sum is ${a + b} ${ A.foo() }") println( a % b) println(c in a..b) a %= 2 a && b a *= 2 a++ b+=2 b-- a-=1 a /= 2 a <= b b == a a >= b nullable!! a != b a || b a?.foo a ?: b } class B // no braces data class C( val s: String ) fun moreOperators(arg: Any?) { when(arg) { !is Int -> { } is Number -> {} in emptyList() -> { } } if(arg !== Boolean) println(arg === Unit) } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION) @Retention(AnnotationRetention.SOURCE) annotation class Annotated @Annotated class A { @Annotated fun a( @Annotated param: Int ) { @Annotated val y = 0 } } open class TUpper fun generic() = 123 class Holder class Holder2 var holder1: Holder? = null class Some( val holder2: Holder? = null ) { var holder3: Holder? = null fun example() { var holder4: Holder? = null } } fun > sort(list: List) { } class X { companion object { } suspend inline fun generic(t: T) { print(T::class.simpleName) } } // eof comment