KOTLINMETA Telegram 163
Kotlin Meta
suspend/composable/etc context propagation Также inline-функции позволяют распространить suspend/composable/какой-либо другой контекст стороны вызова в код передаваемой лямбды. Именно благодаря этому, к примеру, в map мы можем вызывать suspend функции, несмотря…
реификация типов

В Kotlin присутствует стирание типов в compile-time. Это значит, что все дженерики будут выглядеть в runtime одинаково и в следующем коде будет ошибка:


fun <T> checkType(item: Any): Boolean = item is T
// err: cannot check for instance of erased type T


Однако с inline функциями можно пометить тип как reified и этот код уже скомпилируется:


inline fun <reified T> checkType(item: Any): Boolean = item is T
72



tgoop.com/kotlinmeta/163
Create:
Last Update:

реификация типов

В Kotlin присутствует стирание типов в compile-time. Это значит, что все дженерики будут выглядеть в runtime одинаково и в следующем коде будет ошибка:


fun <T> checkType(item: Any): Boolean = item is T
// err: cannot check for instance of erased type T


Однако с inline функциями можно пометить тип как reified и этот код уже скомпилируется:


inline fun <reified T> checkType(item: Any): Boolean = item is T

BY Kotlin Meta





Share with your friend now:
tgoop.com/kotlinmeta/163

View MORE
Open in Telegram


Telegram News

Date: |

best-secure-messaging-apps-shutterstock-1892950018.jpg As of Thursday, the SUCK Channel had 34,146 subscribers, with only one message dated August 28, 2020. It was an announcement stating that police had removed all posts on the channel because its content “contravenes the laws of Hong Kong.” The administrator of a telegram group, "Suck Channel," was sentenced to six years and six months in prison for seven counts of incitement yesterday. Informative Don’t publish new content at nighttime. Since not all users disable notifications for the night, you risk inadvertently disturbing them.
from us


Telegram Kotlin Meta
FROM American