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: |

For crypto enthusiasts, there was the “gm” app, a self-described “meme app” which only allowed users to greet each other with “gm,” or “good morning,” a common acronym thrown around on Crypto Twitter and Discord. But the gm app was shut down back in September after a hacker reportedly gained access to user data. With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. Administrators Just as the Bitcoin turmoil continues, crypto traders have taken to Telegram to voice their feelings. Crypto investors can reduce their anxiety about losses by joining the “Bear Market Screaming Therapy Group” on Telegram.
from us


Telegram Kotlin Meta
FROM American