# Regarding function arguments

**URL:** <https://discuss.kotlinlang.org/t/regarding-function-arguments/8244>\
**Category:** Language Design\
**Created:** [June 21, 2018, 9:26pm UTC](https://discuss.kotlinlang.org/t/regarding-function-arguments/8244 "2018-06-21T21:26:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aryanadi2017](https://avatars.discourse-cdn.com/v4/letter/a/c0e974/32.png) [@aryanadi2017](https://discuss.kotlinlang.org/u/aryanadi2017)\
**Post date:** [June 21, 2018, 9:26pm UTC](https://discuss.kotlinlang.org/t/regarding-function-arguments/8244/1 "2018-06-21T21:26:21Z")

</div>

Hello JetBrains. It’s one of you’re Kotlin programmer. I wanted to bring to notice that functions in Kotlin take their arguments in ‘val’ value and not ‘var’ value. This won’t let us do any operation on the arguments of function or use them in an operation inside the function. Most of the programming language don’t show such kind of behavior. If possible please look into the matter as this very important in terms of programming and android development perspective.

---

<div class="post-metadata">

**Author:** ![forinil2](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/forinil2/32/2465_2.png) [@forinil2](https://discuss.kotlinlang.org/u/forinil2)\
**Post date:** [June 22, 2018, 8:04am UTC](https://discuss.kotlinlang.org/t/regarding-function-arguments/8244/2 "2018-06-22T08:04:33Z")

</div>

This topic has already been discussed [on this forum](https://discuss.kotlinlang.org/t/method-parameters-and-mutable-variables/333).

The consensus seem to be that method parameters should be final to avoid introducing hard to detect bugs in the code.

---

<div class="post-metadata">

**Author:** ![Radzell](https://avatars.discourse-cdn.com/v4/letter/r/65b543/32.png) [@Radzell](https://discuss.kotlinlang.org/u/Radzell)\
**Post date:** [June 23, 2018, 10:01pm UTC](https://discuss.kotlinlang.org/t/regarding-function-arguments/8244/3 "2018-06-23T22:01:04Z")

</div>

Thats probably not going to change. It like making classes final is a tool to prevent bad coding practices. If you want to modify a parameter you should make a copy then do work on the copy.

---

<div class="post-metadata">

**Author:** ![fatjoe79](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/fatjoe79/32/4221_2.png) [@fatjoe79](https://discuss.kotlinlang.org/u/fatjoe79)\
**Post date:** [June 24, 2018, 5:31am UTC](https://discuss.kotlinlang.org/t/regarding-function-arguments/8244/4 "2018-06-24T05:31:06Z")

</div>

Note that you can introduce a non-final variable with the same name as the argument. This is quite useful, as it will prevent accidental usage of the wrong name.

```
fun foo(bar: String) {
    var bar = bar
    // now bar is mutable
}

```
