# Yazım Kuralları

## 🤵 Adlandırmalar

```kotlin
// Test için özel adlandırmalar
class MyTestCase {
     @Test fun `ensure everything works`() { /*...*/ }
     
     @Test fun ensureEverythingWorks_onAndroid() { /*...*/ }
}

// Property
val isEmpty: Boolean get() = size == 0
```

## 👮‍♂️ Koşul Kullanımları

```kotlin
when (foo) {
    true -> bar() // good
    false -> { baz() } // bad
    else -> {}
}

// 2 değişken için if öneriliyor
if (x == null) /* ... */ else /* ... */
```

## ⛓️ Zincir Kullanımlar

* 👆 `?` başta olur

```kotlin
val anchor = owner
    ?.firstChild!!
    .siblings(forward = true)
    .dropWhile { it is PsiComment || it is PsiWhiteSpace }
```

## 🚄 Keyword Sırası

```kotlin
public / protected / private / internal
expect / actual
final / open / abstract / sealed / const
external
override
lateinit
tailrec
vararg
suspend
inner
enum / annotation
companion
inline
infix
operator
data
```

## 📜 Kotlin Doc

![](/files/N40Aj0YcDVDi9HillFo0)

```kotlin
// Avoid doing this:

/**
 * Returns the absolute value of the given number.
 * @param number The number to return the absolute value for.
 * @return The absolute value.
 */
fun abs(number: Int) { /*...*/ }

// Do this instead:

/**
 * Returns the absolute value of the given [number].
 */
fun abs(number: Int) { /*...*/ }
```

## 🏗️ Function Builder

* 👮‍♂️ `from<Name>` adı tercih edilmeli
* ⭐ `fromPolar`

```kotlin
class Point(val x: Double, val y: Double) {
    companion object {
        fun fromPolar(angle: Double, radius: Double) = Point(...)
    }
}
```

## 🧐 Kaynaklar

{% embed url="<https://kotlinlang.org/docs/reference/kotlin-doc.html>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/arsiv/kotlin/yazim-kurallari.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
