| Swift | Kotlin | Notes |
|---|---|---|
| let | val | immutable |
| var | var | mutable |
| nil | null | undefined |
| func | fun | function |
| protocol | trait | abastract/virtual |
| init | constructor | initialization |
| -> | : | return value |
| Any | AnyObject | |
| ! | !! | force unwrap |
| -> | : | return value |
| println |
lang:
- Eplicit Types:
var name:String = "matt" - Type Coercion:
val age = 2 - Typing: both strong and static
- String Interpolation:
var message = "$matt scored a ${score} " + "today." - Rang Operators (Inclusive):
for i in 0..<count {vsfor (i in 0..count - 1) { - Etensions
- Map, Filter, Reduce:
- vargs
- Tuple support:
fun myTupel = (2,3,5) - Supports Optionals:
val name:String? = nullexplicity unwrap:name!!optional unwrapname? - Closer/lambda support
- Name parameters (arguments)
- Computed properties
get{ "hello" }andget() = "hello" switchwhen () {
Arrays (similar-ish, Kotlin Array vs Kotlin ArrayList ):
- Kotlin (mutable fixed size):
val numbers = Array<Int>(5){0} - Kotlin (mutable array, variable size):
var names = ArrayList<String>() - Kotlin (immutable array):
val days = arrayOf("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
Dictionaries Maps (similar-ish, HashMap vs mapOf):
- Kotlin (variable capacity):
var namesWithAges = HashMap<String, Int>() - Kotlin (fixed capacity):
var namesWithAges = HashMap<String, Int>(20)// - similar assignment. Kotlin:
namesWithAges["John Doe"] = 34 - Kotlin (immutable):
val namesWithAges = mapOf("John Doe" to 34, "Jane Doe" to 29)
concept of mutability and immutability properties:
- mutable properties:
varvsvar - immutable Properties:
letvsval
swift supports (kotlin does not):
guardtypealias- tuples ( kotlin onlys supports tuples as return types)
kotlin supports (swift does not):
-
guard -
class specific importation
class import -
@annotations -
data classesvsstruct(value types) -
kotlin classes are
finalby default -
memory allocation ?
-
functional closers? un-winding?
Things to investigate:
- kotlin has no semantic for passing data by value ( struct ) ? Im not 100% sure if this is true
UIViewControllervsActivityUIViewvsView/WidgetStoryboard/xibvsxml layoutseguevsintentsimulatorvsemulator2x,3xvsmdpi,hdpi,...gradlevspods
- Kotlin supports targets: ( JVM, Objective-C, JavaScript)
jsonvsgsonvsjxson: faster?
https://web.stanford.edu/class/cs193a/videos.shtml
- Lecture 01: Course introduction and first app
- Lecture 02: Layout
- Lecture 03: Widgets; Lists
- Lecture 04: More Lists; Files and Storage
- Lecture 05: Multiple Activities and Intents
- https://adorahack.com/zero-to-kotlin-hero-kotlin-extensions
- https://adorahack.com/zero-to-kotlin-hero-data-classes-and-sealed-classes
- https://adorahack.com/zero-to-kotlin-hero-data-classes-and-sealed-classes
- https://adorahack.com/say-goodbye-to-nulls
- https://adorahack.com/zero-to-kotlin-hero-classes-in-kotlin
- https://adorahack.com/zero-to-kotlin-hero-variables-and-data-types