You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Throws an exception when trying to encode or decode.
257
+
*
258
+
* It is used as a dummy in case it is necessary to pass a type to a parameterized class. At the same time, it is expected that this generic type will not participate in serialization.
Copy file name to clipboardExpand all lines: docs/builtin-classes.md
+29Lines changed: 29 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,6 +24,7 @@ including the standard collections, is built into Kotlin Serialization. This cha
24
24
*[Maps](#maps)
25
25
*[Unit and singleton objects](#unit-and-singleton-objects)
26
26
*[Duration](#duration)
27
+
*[Nothing](#nothing)
27
28
28
29
<!--- END -->
29
30
@@ -405,6 +406,33 @@ Duration is serialized as a string in the ISO-8601-2 format.
405
406
406
407
<!--- TEST -->
407
408
409
+
410
+
## Nothing
411
+
412
+
By default, [Nothing] is a serializable class. However, since there are no instances of this class, it is impossible to encode or decode its values - any attempt will cause an exception.
413
+
414
+
This serializer is used when syntactically some type is needed, but it is not actually used in serialization. For example, when using parameterized polymorphic base classes:
415
+
```kotlin
416
+
@Serializable
417
+
sealedclassParametrizedParent<outR> {
418
+
@Serializable
419
+
data classChildWithoutParameter(valvalue:Int) : ParametrizedParent<Nothing>()
0 commit comments