# Error unresolved reference: isOdd

**URL:** <https://discuss.kotlinlang.org/t/error-unresolved-reference-isodd/24956>\
**Category:** Uncategorized\
**Created:** [June 5, 2022, 6:46pm UTC](https://discuss.kotlinlang.org/t/error-unresolved-reference-isodd/24956 "2022-06-05T18:46:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yanadior9029](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@yanadior9029](https://discuss.kotlinlang.org/u/yanadior9029)\
**Post date:** [June 5, 2022, 6:46pm UTC](https://discuss.kotlinlang.org/t/error-unresolved-reference-isodd/24956/1 "2022-06-05T18:46:49Z")

</div>

Hi All,  
I am going through the kotlin tutorial(link below)

> **[Conditions and loops | Kotlin](https://kotlinlang.org/docs/control-flow.html#when-expression)**

One of the example as part of “when” expression is

val x = 5  
val y = 10  
when {  
x.isOdd() → print(“x is odd”)  
y.isEven() → print(“y is even”)  
else → print(“x+y is odd”)  
}

However when i try to execute this code, i get an error  
unresolved reference: isOdd  
unresolved reference: isEven

[https://pl.kotl.in/q5cC2kN2I](https://pl.kotl.in/q5cC2kN2I)

i have searched kotlin website and forums but could not find any results.

Please advice me to resolve this issue.

Thank you for your time and attention.

---

<div class="post-metadata">

**Author:** ![broot](https://avatars.discourse-cdn.com/v4/letter/b/a88e57/32.png) [@broot](https://discuss.kotlinlang.org/u/broot)\
**Post date:** [June 5, 2022, 7:32pm UTC](https://discuss.kotlinlang.org/t/error-unresolved-reference-isodd/24956/2 "2022-06-05T19:32:13Z")

</div>

That was just an example, because it is rather obvious for the reader, what such `isOdd` and `isEven` do. Similarly, `x` and `y` in this example aren’t defined anywhere.

You can very easily create these functions by yourself:

```kotlin
fun Int.isOdd() = this % 2 != 0
fun Int.isEven() = this % 2 == 0

```

---

<div class="post-metadata">

**Author:** ![yanadior9029](https://avatars.discourse-cdn.com/v4/letter/y/e9bcb4/32.png) [@yanadior9029](https://discuss.kotlinlang.org/u/yanadior9029)\
**Post date:** [June 6, 2022, 1:18am UTC](https://discuss.kotlinlang.org/t/error-unresolved-reference-isodd/24956/3 "2022-06-06T01:18:17Z")

</div>

Thank you for your guidance
