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? = null
explicity unwrap:name!!
optional unwrapname?
- Closer/lambda support
- Name parameters (arguments)
- Computed properties
get{ "hello" }
andget() = "hello"
switch
when () {
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:
var
vsvar
- immutable Properties:
let
vsval
swift supports (kotlin does not):
guard
typealias
- tuples ( kotlin onlys supports tuples as return types)
kotlin supports (swift does not):
-
guard
-
class specific importation
class import
-
@annotations
-
data classes
vsstruct
(value types) -
kotlin classes are
final
by 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
UIViewController
vsActivity
UIView
vsView/Widget
Storyboard/xib
vsxml layout
segue
vsintent
simulator
vsemulator
2x,3x
vsmdpi,hdpi,...
gradle
vspods
- Kotlin supports targets: ( JVM, Objective-C, JavaScript)
json
vsgson
vsjxson
: 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