LoginSignup
0
0

More than 5 years have passed since last update.

Unit Type

Last updated at Posted at 2017-05-30

在邊練習 Kotlin 的時候,看方法定義看到了一個型別

Unit

八竿子打不著的無法猜出那是什麼東西,查了一下就把它筆記下來。

官方文件是這樣寫的:

The type with only one value: the Unit object. This type corresponds to the void type in Java.
- cf: Unit

:bulb: :bulb: :bulb: :smirk:

所以他其實就是 void

如果有個回傳值,或是 block 的定義是寫 -> Unit 的話,就是可以不用回傳的意思 :white_flower:

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0