# Var in parameters definition

**URL:** <https://discuss.kotlinlang.org/t/var-in-parameters-definition/22912>\
**Category:** Language Design\
**Created:** [September 9, 2021, 3:57pm UTC](https://discuss.kotlinlang.org/t/var-in-parameters-definition/22912 "2021-09-09T15:57:26Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![stachenov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/stachenov/32/6199_2.png) [@stachenov](https://discuss.kotlinlang.org/u/stachenov)\
**Post date:** [September 15, 2021, 6:40pm UTC](https://discuss.kotlinlang.org/t/var-in-parameters-definition/22912/6 "2021-09-15T18:40:18Z")

</div>

> [@brymher](#):
>
> This is what’s supported
> 
> ```auto
> fun simple(age:Int):Int{
> var age1 = age
> // make changes to age code here
> return age
> }
> 
> ```

This is what’s also supported:

```auto
fun simple(age:Int):Int{
var age = age
// make changes to age code here
return age
}

```

This leads to a warning in IDEA, but if your coding style allows it, just disable the corresponding inspection.

Instead of mutating parameters (which would be confusing), Kotlin may extend its support for name shadowing, as was discussed here:

> [@Rust-style variable shadowing](https://discuss.kotlinlang.org/t/rust-style-variable-shadowing/16338):
>
> Preface Having worked with Rust recently, I’ve come to like one very specific feature a lot: Variable shadowing. In rust it is possible to shadow variable names without warnings or errors, even in the same scope, and I propose adding this feature to Kotlin. Here is an example of how it works in rust: let foo: String = "4".to\_string(); let foo: Option\<i32\> = foo.parse().ok(); // parse foo into the equivalent of Int? let foo: i32 = foo.unwrap\_or(1234); // equivalent of foo ?: 1234 How it wor…

---

_[View the full topic](https://discuss.kotlinlang.org/t/var-in-parameters-definition/22912)._
