# Kotlin Reflection and Default Values

**URL:** <https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254>\
**Category:** Libraries\
**Created:** [February 1, 2017, 3:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254 "2017-02-01T15:34:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rhencke](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/rhencke/32/1978_2.png) [@rhencke](https://discuss.kotlinlang.org/u/rhencke)\
**Post date:** [February 1, 2017, 3:34pm UTC](https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254/1 "2017-02-01T15:34:20Z")

</div>

Hey folks,

Is it possible using Kotlin’s reflection, or some other mechanism, to determine the default value for a function parameter? IntelliJ IDEA is able to pull this information to provide code completion tips showing the default value when showing Parameter Info, but I wasn’t able figure out how they achieve this. I found [this](https://discuss.kotlinlang.org/t/default-values-and-reflection/874) which says, at least as of 2013, it wasn’t possible, but that was a while back. (I am mainly hoping to pull the value for documentation purposes, similar to how Parameter Info does.)

Thanks!

---

<div class="post-metadata">

**Author:** ![yole](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/yole/32/1425_2.png) [@yole](https://discuss.kotlinlang.org/u/yole)\
**Post date:** [February 1, 2017, 4:40pm UTC](https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254/2 "2017-02-01T16:40:52Z")

</div>

The default value of a method parameter is an arbitrary expression which can only be represented as a chunk of bytecode; there is no other representation that can be used in reflection. Parameter Info retrieves default parameter values by parsing source code.

---

<div class="post-metadata">

**Author:** ![rhencke](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/rhencke/32/1978_2.png) [@rhencke](https://discuss.kotlinlang.org/u/rhencke)\
**Post date:** [February 1, 2017, 5:01pm UTC](https://discuss.kotlinlang.org/t/kotlin-reflection-and-default-values/2254/3 "2017-02-01T17:01:16Z")

</div>

Thank you @yole! I’ll look into pursuing the same approach as Parameter Info, then.
