kotlin Function(R) is the unified supertype of all function types It is param- eterized over function return type R Built-in integer types Kotlin supports the following
Previous PDF | Next PDF |
[PDF] Download PDF - Kotlin language specification
kotlin Function(R) is the unified supertype of all function types It is param- eterized over function return type R Built-in integer types Kotlin supports the following
[PDF] Type inference - Kotlin language specification
ment/expression scope; • Function signature type inference, for inferring types of function return values and/or parameters Type inference is a type constraint
[PDF] Expressions - Kotlin language specification
Otherwise, if the value is greater than maximum kotlin Int value (see The compareTo operator function must have return type kotlin Int, otherwise
[PDF] Integer types - Kotlin language specification
for a function returning nothing), but is different in that there is, in fact, a single value of Boolean is the boolean logic type of Kotlin, representing a value which
[PDF] functions - Kotlin language specification
parameters and default parameter values, just as regular functions Please refer componentN function has the same type as this property and returns the value
[PDF] Download Kotlin 1430 documentation (PDF)
and there was no common function that would return the numeric value 4 for In Kotlin 1 4, you can use callable references to functions returning any type in
[PDF] Type system - Kotlin language specification
Function kotlin Function(R) is the unified supertype of all function types It is param- eterized over function return type R Built-in integer types Kotlin supports the
[PDF] GETTING STARTED WITH INTRODUCTION WHERE TO START
The return type of the main is Unit, also prefaced by a colon In case of a Unit Functions and variables in Kotlin may be declared at "top- level", i e directly
[PDF] type inference - JetBrains
Contract: if the function returns a given value, a condition is satisfied isNullOrEmpty, isNullOrBlank kotlin test: assertTrue, assertFalse, assertNotNull check
[PDF] raywenderlichcom Kotlin Cheat Sheet and Quick Reference
Kotlin Cheat Sheet and Quick Reference Version 1 0 Visit for more Android/ Kotlin resources and tutorials Function with parameters and return value
[PDF] kotlin online course
[PDF] kotlin oop cheat sheet
[PDF] kotlin programming by example "pdf"
[PDF] kotlin quick reference
[PDF] kotlin training
[PDF] kotlin tutorial android app
[PDF] kotlin tutorial android developer
[PDF] kotlin tutorial android for beginners pdf
[PDF] kotlin tutorial android javatpoint
[PDF] kotlin tutorial android pdf
[PDF] kotlin tutorial android studio pdf
[PDF] kotlin tutorial android tutorialspoint
[PDF] kotlin version
[PDF] kpmg balance sheet
Kotlin language specification
Version 1.8-rfc+0.1
Marat Akhin Mikhail Belyaev
iiContents
I Kotlin/Core 1
Introduction 3
Compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Experimental features . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Syntax and grammar 7
1.1 Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71.2 Lexical grammar . . . . . . . . . . . . . . . . . . . . . . . . . . .
71.2.1 Whitespace and comments . . . . . . . . . . . . . . . . . .
71.2.2 Keywords and operators . . . . . . . . . . . . . . . . . . .
81.2.3 Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . .
151.2.4 Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . .
161.2.5 String mode grammar . . . . . . . . . . . . . . . . . . . .
181.2.6 Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
191.3 Syntax grammar . . . . . . . . . . . . . . . . . . . . . . . . . . .
231.4 Documentation comments . . . . . . . . . . . . . . . . . . . . . .
422 Type system 43
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.1 Type kinds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
452.1.1 Built-in types . . . . . . . . . . . . . . . . . . . . . . . . .
46kotlin.Any. . . . . . . . . . . . . . . . . . . . . . . . . .46 kotlin.Nothing. . . . . . . . . . . . . . . . . . . . . . .46 kotlin.Function. . . . . . . . . . . . . . . . . . . . . .46 Built-in integer types . . . . . . . . . . . . . . . . . . . . . 46
Array types . . . . . . . . . . . . . . . . . . . . . . . . . . 46
2.1.2 Classifier types . . . . . . . . . . . . . . . . . . . . . . . .
47Simple classifier types . . . . . . . . . . . . . . . . . . . . 48
Parameterized classifier types . . . . . . . . . . . . . . . . 48
iii ivCONTENTS
2.1.3 Type parameters . . . . . . . . . . . . . . . . . . . . . . .
50Function type parameters . . . . . . . . . . . . . . . . . . 51
Mixed-site variance . . . . . . . . . . . . . . . . . . . . . . 51
Declaration-site variance . . . . . . . . . . . . . . . . . . . 52
Use-site variance . . . . . . . . . . . . . . . . . . . . . . . 54
2.1.4 Type capturing . . . . . . . . . . . . . . . . . . . . . . . .
552.1.5 Type containment . . . . . . . . . . . . . . . . . . . . . .
602.1.6 Function types . . . . . . . . . . . . . . . . . . . . . . . .
61Suspending function types . . . . . . . . . . . . . . . . . . 62
2.1.7 Flexible types . . . . . . . . . . . . . . . . . . . . . . . . .
63Dynamic type . . . . . . . . . . . . . . . . . . . . . . . . . 64
Platform types . . . . . . . . . . . . . . . . . . . . . . . . 64
2.1.8 Nullable types . . . . . . . . . . . . . . . . . . . . . . . .
64Nullability lozenge . . . . . . . . . . . . . . . . . . . . . . 65
Definitely non-nullable types . . . . . . . . . . . . . . . . 66
2.1.9 Intersection types . . . . . . . . . . . . . . . . . . . . . . .
672.1.10 Integer literal types . . . . . . . . . . . . . . . . . . . . .
672.1.11 Union types . . . . . . . . . . . . . . . . . . . . . . . . . .
672.2 Type contexts and scopes . . . . . . . . . . . . . . . . . . . . . .
682.2.1 Inner and nested type contexts . . . . . . . . . . . . . . .
682.3 Subtyping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
692.3.1 Subtyping rules . . . . . . . . . . . . . . . . . . . . . . . .
692.3.2 Subtyping for flexible types . . . . . . . . . . . . . . . . .
692.3.3 Subtyping for intersection types . . . . . . . . . . . . . . .
702.3.4 Subtyping for integer literal types . . . . . . . . . . . . .
702.3.5 Subtyping for nullable types . . . . . . . . . . . . . . . . .
712.4 Upper and lower bounds . . . . . . . . . . . . . . . . . . . . . . .
732.4.1 Least upper bound . . . . . . . . . . . . . . . . . . . . . .
732.4.2 Greatest lower bound . . . . . . . . . . . . . . . . . . . .
752.5 Type approximation . . . . . . . . . . . . . . . . . . . . . . . . .
762.6 Type decaying . . . . . . . . . . . . . . . . . . . . . . . . . . . .
76References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
3 Built-in types and their semantics 79
3.1kotlin.Any. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
3.2kotlin.Nothing. . . . . . . . . . . . . . . . . . . . . . . . . . .80
3.3kotlin.Unit. . . . . . . . . . . . . . . . . . . . . . . . . . . . .80
3.4kotlin.Boolean. . . . . . . . . . . . . . . . . . . . . . . . . . .80
3.5 Built-in integer types . . . . . . . . . . . . . . . . . . . . . . . . .
803.5.1 Integer type widening . . . . . . . . . . . . . . . . . . . .
813.6 Built-in floating point arithmetic types . . . . . . . . . . . . . . .
823.7kotlin.Char. . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
3.8kotlin.String. . . . . . . . . . . . . . . . . . . . . . . . . . . .83
3.9kotlin.Enum. . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
3.10 Built-in array types . . . . . . . . . . . . . . . . . . . . . . . . . .
843.10.1 Specialized array types . . . . . . . . . . . . . . . . . . . .
84CONTENTSv
3.11 Iterator types . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
853.11.1 Specialized iterator types . . . . . . . . . . . . . . . . . .
853.12kotlin.Throwable. . . . . . . . . . . . . . . . . . . . . . . . . .86
3.13kotlin.Comparable. . . . . . . . . . . . . . . . . . . . . . . . .86
3.14kotlin.Function. . . . . . . . . . . . . . . . . . . . . . . . . .86
3.15 Built-in annotation types . . . . . . . . . . . . . . . . . . . . . .
863.16 Reflection support builtin types . . . . . . . . . . . . . . . . . . .
873.16.1kotlin.reflect.KClass. . . . . . . . . . . . . . . . . .87
3.16.2kotlin.reflect.KCallable. . . . . . . . . . . . . . . .87
3.16.3kotlin.reflect.KProperty. . . . . . . . . . . . . . . .87
3.16.4kotlin.reflect.KFunction. . . . . . . . . . . . . . . .87
4 Declarations 89
Glossary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
4.1 Classifier declaration . . . . . . . . . . . . . . . . . . . . . . . . .
894.1.1 Class declaration . . . . . . . . . . . . . . . . . . . . . . .
90Constructor declaration . . . . . . . . . . . . . . . . . . . 92
Constructor declaration scopes . . . . . . . . . . . 94
Nested and inner classifiers . . . . . . . . . . . . . . . . . 94
Inheritance delegation . . . . . . . . . . . . . . . . . . . . 96
Abstract classes . . . . . . . . . . . . . . . . . . . . . . . . 98
4.1.2 Data class declaration . . . . . . . . . . . . . . . . . . . .
984.1.3 Enum class declaration . . . . . . . . . . . . . . . . . . .
1014.1.4 Annotation class declaration . . . . . . . . . . . . . . . .
1034.1.5 Value class declaration . . . . . . . . . . . . . . . . . . . .
1044.1.6 Interface declaration . . . . . . . . . . . . . . . . . . . . .
105Functional interface declaration . . . . . . . . . . . . . . . 106
4.1.7 Object declaration . . . . . . . . . . . . . . . . . . . . . .
1074.1.8 Local class declaration . . . . . . . . . . . . . . . . . . . .
1084.1.9 Classifier initialization . . . . . . . . . . . . . . . . . . . .
1084.1.10 Classifier declaration scopes . . . . . . . . . . . . . . . . .
1104.2 Function declaration . . . . . . . . . . . . . . . . . . . . . . . . .
1114.2.1 Function signature . . . . . . . . . . . . . . . . . . . . . .
1124.2.2 Named, positional and default parameters . . . . . . . . .
1134.2.3 Variable length parameters . . . . . . . . . . . . . . . . .
1144.2.4 Extension function declaration . . . . . . . . . . . . . . .
1154.2.5 Inlining . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1164.2.6 Infix functions . . . . . . . . . . . . . . . . . . . . . . . .
1174.2.7 Local function declaration . . . . . . . . . . . . . . . . . .
1184.2.8 Tail recursion optimization . . . . . . . . . . . . . . . . .
1184.2.9 Function declaration scopes . . . . . . . . . . . . . . . . .
1194.3 Property declaration . . . . . . . . . . . . . . . . . . . . . . . . .
1194.3.1 Read-only property declaration . . . . . . . . . . . . . . .
1204.3.2 Mutable property declaration . . . . . . . . . . . . . . . .
1204.3.3 Local property declaration . . . . . . . . . . . . . . . . . .
121viCONTENTS
4.3.4 Getters and setters . . . . . . . . . . . . . . . . . . . . . .
1214.3.5 Delegated property declaration . . . . . . . . . . . . . . .
1224.3.6 Extension property declaration . . . . . . . . . . . . . . .
1264.3.7 Property initialization . . . . . . . . . . . . . . . . . . . .
1274.3.8 Constant properties . . . . . . . . . . . . . . . . . . . . .
1274.3.9 Late-initialized properties . . . . . . . . . . . . . . . . . .
1284.3.10 Property declaration scopes . . . . . . . . . . . . . . . . .
1284.4 Type alias . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1294.5 Declarations with type parameters . . . . . . . . . . . . . . . . .
1294.5.1 Type parameter variance . . . . . . . . . . . . . . . . . .
1304.5.2 Reified type parameters . . . . . . . . . . . . . . . . . . .
1324.5.3 Underscore type arguments . . . . . . . . . . . . . . . . .
1324.6 Declaration visibility . . . . . . . . . . . . . . . . . . . . . . . . .
1335 Inheritance 137
5.1 Classifier type inheritance . . . . . . . . . . . . . . . . . . . . . .
1375.1.1 Abstract classes . . . . . . . . . . . . . . . . . . . . . . . .
1385.1.2 Sealed classes and interfaces . . . . . . . . . . . . . . . . .
1385.1.3 Inheritance from built-in types . . . . . . . . . . . . . . .
1385.2 Matching and subsumption of declarations . . . . . . . . . . . . .
1385.3 Inheriting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1395.4 Overriding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1396 Scopes and identifiers 143
6.1 Linked scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1456.2 Identifiers and paths . . . . . . . . . . . . . . . . . . . . . . . . .
1466.3 Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1467 Statements 147
7.1 Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1477.1.1 Simple assignments . . . . . . . . . . . . . . . . . . . . . .
1487.1.2 Operator assignments . . . . . . . . . . . . . . . . . . . .
1487.1.3 Safe assignments . . . . . . . . . . . . . . . . . . . . . . .
149quotesdbs_dbs10.pdfusesText_16