https://kotlinlang.org logo
#announcements
Title
# announcements
k

kartikpatodi

11/05/2017, 6:56 AM
Can anyone explain what is
reified
I'm unable to understand the concept behind this one
k

karelpeeters

11/05/2017, 8:10 AM
k

kartikpatodi

11/05/2017, 8:20 AM
ok so is it just syntax sugar and does the same reflection behind the scenes so we dont have to see the ugly code? @karelpeeters
k

karelpeeters

11/05/2017, 8:22 AM
It doesn't do reflection at all, since it is always
inline
it can inline the type parameter in things like
foo is T
as well. But yes, the purpose is to hide avoid ugly reflection code.
k

kartikpatodi

11/05/2017, 8:22 AM
got it thanks
@karelpeeters can o tell why this example provided in the docs throwing exception
Copy code
inline fun <reified T> membersOf() = T::class.members

fun main(s: Array<String>) {
    println(membersOf<StringBuilder>().joinToString("\n"))
}
k

karelpeeters

11/05/2017, 6:23 PM
I can't test right now (not at a computer), does it work directly, ie. without reified funtion calls?
k

kartikpatodi

11/06/2017, 7:42 PM
It works in the IDE but throws error in try.kotlinlang.org
k

karelpeeters

11/06/2017, 8:02 PM
Then there's probably something wrong with the site.
k

kartikpatodi

11/06/2017, 8:16 PM
I guess and also they must provide an option to try the beta releases online Like an option btw stable and beta
2 Views