Arrays (T[])
Arrays are represented with the most common and efficient native data structures, such as std::vector<T> in C++ or Array<T> in Swift and Kotlin.
- TypeScript
- Swift
- Kotlin
- C++
import { type HybridObject, iOS } from 'nitro-core'
@iOS(...)
export declare class Contacts extends HybridObject {
getAllUsers(): User[]
}
class HybridContacts: HybridContactsSpec {
func getAllUsers() throws -> [User]
}
class HybridContacts: HybridContactsSpec() {
override fun getAllUsers(): Array<User>
}
class HybridContacts: public HybridContactsSpec {
std::vector<User> getAllUsers() override;
};
Kotlin PrimitiveArray
As a performance improvement, the JNI (C++ -> Kotlin interface) provides Primitive Array datatypes which can avoid boxing primitives into Objects, and provides bulk copy methods.
This makes all array operations a lot faster, and Nitrogen is smart enough to ✨automagically✨ use Primitive Arrays whenever possible.
This will replace the following arrays:
Array<Double>->DoubleArrayArray<Boolean>->BooleanArrayArray<Long>->LongArray