# Removing Constructor Keyword

**URL:** <https://discuss.kotlinlang.org/t/removing-constructor-keyword/16234>\
**Category:** Support\
**Created:** [February 6, 2020, 7:13am UTC](https://discuss.kotlinlang.org/t/removing-constructor-keyword/16234 "2020-02-06T07:13:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagarpatel288](https://avatars.discourse-cdn.com/v4/letter/s/48db29/32.png) [@sagarpatel288](https://discuss.kotlinlang.org/u/sagarpatel288)\
**Post date:** [February 6, 2020, 7:13am UTC](https://discuss.kotlinlang.org/t/removing-constructor-keyword/16234/1 "2020-02-06T07:13:02Z")

</div>

I am learning kotlin and when I don’t understand many things, first I Google! However, even after that if I don’t understand, I post my concern here! I hope, I am not disturbing anyone!

So, I was reading about the constructor keyword in kotlin and there is one confusion.

According to document:  
[https://kotlinlang.org/docs/reference/classes.html](https://kotlinlang.org/docs/reference/classes.html)

> If the primary constructor does not have any annotations or visibility modifiers, the constructor keyword can be omitted

Does that mean we cannot remove constructor keyword if our properties have any kind of annotation or even when our properties have visibility modifier?

What I have observed is quite different than what document says! We can remove the constructor keyword even if the properties have any visibility modifiers!

Have I got this wrong?

---

<div class="post-metadata">

**Author:** ![Wasabi375](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/wasabi375/32/4741_2.png) [@Wasabi375](https://discuss.kotlinlang.org/u/Wasabi375)\
**Post date:** [February 6, 2020, 7:25am UTC](https://discuss.kotlinlang.org/t/removing-constructor-keyword/16234/2 "2020-02-06T07:25:45Z")

</div>

No, this line only is about visibility modifiers and annotations on the primary constructor.

```kotlin
class Foo internal constructor() // can't remove the constructor keyword here
class Bar constructor() // here you can remove the keyword

```

Same is true for annotations that apply to the primary constructor.

There is an example for this in the docs as well a bit further down. Maybe you just missed it 😉

> If the constructor has annotations or visibility modifiers, the _constructor_ keyword is required, and the modifiers go before it:

```kotlin
class Customer public @Inject constructor(name: String) { /*...*/ }

```
