getAndRemove

inline fun <T : Any> getAndRemove(key: CompoundKey<T>): T?(source)

Removes the current value associated with the given key. Additionally, this function returns the value that was removed, if one was removed. Otherwise, the return value will be null.

Note: Calling this function may result in deserialization of the value which was deleted from the internal NbtCompound, if the removed value was not loaded into memory.