Swift & Kotlin operators
| operators | SWift | Kotlin |
|---|---|---|
| ==, != | value equality | value equality |
| ===, !== | referential equality | referential equality |
| .. | - | [1..3] //range result: 1,2,3 |
| … | [1…3] //range result: 1,2,3 | - |
| ?. | Perform a safe all | Perform a safe all |
| ? : | let r = (10 > 1) ? “yes” : “no” //r=”yes” | - |
| ?: | - | val c = a?:b if a is null, c = b |
| ?? | var c = a ?? b if a is null, c=b | - |
| ? | var a? // a can be null | val a? // a can be null |
| ! | var a! // assert a is not null | - |
| !! | - | val a!! // assert a is not null |
Reference
https://kotlinlang.org/docs/keyword-reference.html#operators-and-special-symbols
https://developer.apple.com/documentation/swift/operator-declarations
Comment