What is the purpose of Unit-returning in functions

前端 未结 3 1983
轮回少年
轮回少年 2020-12-05 09:20

From the Kotlin documentation:

If a function does not return any useful value, its return type is Unit. Unit is a type with only one value — Unit.VALUE. This value d

3条回答
  •  一整个雨季
    2020-12-05 09:41

    UNIT actually contains valuable information, it basically just means "DONE". It just returns the information to the caller, that the method has been finished. This is a real piece of information so it can be seen as the return value of a method.

提交回复
热议问题