# Kotlin null check for multiple nullable var's

**URL:** <https://discuss.kotlinlang.org/t/kotlin-null-check-for-multiple-nullable-vars/1946>\
**Category:** Language Design\
**Created:** [September 1, 2016, 5:35am UTC](https://discuss.kotlinlang.org/t/kotlin-null-check-for-multiple-nullable-vars/1946 "2016-09-01T05:35:43Z")\
**Posts on this page:** 1\
**Showing post:** 55

<div class="post-metadata">

**Author:** ![mo3az014](https://avatars.discourse-cdn.com/v4/letter/m/ecc23a/32.png) [@mo3az014](https://discuss.kotlinlang.org/u/mo3az014)\
**Post date:** [February 18, 2020, 11:14am UTC](https://discuss.kotlinlang.org/t/kotlin-null-check-for-multiple-nullable-vars/1946/55 "2020-02-18T11:14:15Z")

</div>

You can make a Util function that take array of values and check if they all not null  
also added !! operator, but the operator only will leads for a null crashes if null appears.

```auto
    fun test(): Boolean {
        if(isNotNull(var1, var2, var3, var4)) {
            return procceed(var1!!, var2!!, var3!!, var3!!)
        }
        return false;
    }

    private fun isNotNull(vararg objArr: Any?) : Boolean {
        for(obj in objArr) {
            if(obj == null)
                return false
        }
        return true;
    }

```

---

_[View the full topic](https://discuss.kotlinlang.org/t/kotlin-null-check-for-multiple-nullable-vars/1946)._
