Kotlin (programming language): Difference between revisions

Content deleted Content added
Line 36:
 
== Semantics ==
In addition to the [[Class (computer programming)|classes]] and [[Method (computer programming)|methods]] (called member functions in Kotlin) of [[object-oriented programming]] , Kotlin also supports [[procedural programming]] with the use of [[function (computer science)|functions]].<ref>{{cite web | url=http://confluence.jetbrains.com/display/Kotlin/Functions | title=functions | website=jetbrains.com | accessdate=February 8, 2014}}</ref> As in C and C++, the [[entry point]] to a Kotlin [[Computer program|program]] is a function named "main", which is passed an array containing any [[Command-line interface|command line]] arguments. [[Perl]] and Unix/Linux [[shell script]] -style [[string interpolation]] is supported. [[Type inference]] is also supported.
 
'''Hello, world! example'''
Line 48:
</source>
 
Kotlin makes a difference between nullable and non-null datatypes. All nullable objects must be declared with a "?" postfix after the type name. Operations on nullable objects needsneed special care from developers: null-check must be performed before using the value. Kotlin provides null-safe operators to help developers:
* ?. (safe navigation operator) can be used to safely access a method or property of a possibly null object. If the object is null, the method will not be called and the expression evaluates to null.
* ?: also known as [[Elvis operator]]