create

fun create(value: Short): RealmAny

Creates an unmanaged RealmAny instance from a Short value.


fun create(value: Int): RealmAny

Creates an unmanaged RealmAny instance from an Int value.


fun create(value: Byte): RealmAny

Creates an unmanaged RealmAny instance from a Byte value.


fun create(value: Char): RealmAny

Creates an unmanaged RealmAny instance from a Char value.


fun create(value: Long): RealmAny

Creates an unmanaged RealmAny instance from a Long value.


fun create(value: Boolean): RealmAny

Creates an unmanaged RealmAny instance from a Boolean value.


fun create(value: String): RealmAny

Creates an unmanaged RealmAny instance from a String value.


fun create(value: Float): RealmAny

Creates an unmanaged RealmAny instance from a Float value.


fun create(value: Double): RealmAny

Creates an unmanaged RealmAny instance from a Double value.


fun create(value: Decimal128): RealmAny

Creates an unmanaged RealmAny instance from a Decimal128 value.


fun create(value: BsonObjectId): RealmAny

Creates an unmanaged RealmAny instance from a BsonObjectId value.


Creates an unmanaged RealmAny instance from a ByteArray value.


Creates an unmanaged RealmAny instance from a RealmInstant value.


Creates an unmanaged RealmAny instance from a RealmUUID value.


fun <T : RealmObject> create(value: T, clazz: KClass<out T>): RealmAny

Creates an unmanaged RealmAny instance from a RealmObject value and its corresponding KClass.


inline fun <T : RealmObject> create(realmObject: T): RealmAny

Creates an unmanaged RealmAny instance from a RealmObject value.


Creates an unmanaged RealmAny instance from a DynamicRealmObject value.


Creates an unmanaged RealmAny instance from a RealmList of RealmAny values.

To create a RealmAny containing a RealmList of arbitrary values wrapped in RealmAnys use the io.realm.kotlin.ext.realmAnyListOf.

A RealmList<RealmAny?> can contain all RealmAny types, also other collection types:

class SampleObject() : RealmObject {
val realmAnyField: RealmAny? = null
}
val realmObject = copyToRealm(SampleObject())

// List can contain other collections, but only `RealmList<RealmAny>` and
// `RealmDictionary<RealmAny>`.
realmObject.realmAnyField = realmAnyListOf(
// Primitive values
1,
// Lists and dictionaries can contain other collection types
realmListOf(
realmListOf(),
realmDictionaryOf()
),
realmDictionaryOf(
"key1" to realmListOf(),
"key2" to realmDictionaryOf())
)

Creates an unmanaged RealmAny instance from a RealmDictionary of RealmAny values.

To create a RealmAny containing a RealmDictionary of arbitrary values wrapped in RealmAnys use the io.realm.kotlin.ext.realmAnyDictionaryOf.

A RealmDictionary<RealmAny?> can contain all RealmAny types, also other collection types:

class SampleObject() : RealmObject {
val realmAnyField: RealmAny? = null
}
val realmObject = copyToRealm(SampleObject())

// Dictionaries can contain other collections, but only `RealmList<RealmAny>` and
// `RealmDictionary<RealmAny>`.
realmObject.realmAnyField = realmAnyDictionaryOf(
"int" to 5,
// Lists and dictionaries can contain other nested collection types
"list" to realmListOf(
realmListOf(),
realmDictionaryOf()
),
"dictionary" to realmDictionaryOf(
"key1" to realmListOf(),
"key2" to realmDictionaryOf())
)