0% found this document useful (0 votes)
35 views3 pages

Kotlin Advanced Guide

This document is an advanced guide to the Kotlin programming language, covering topics such as Generics, Annotations, Typealias, Delegation, Reflection, and Domain Specific Language (DSL). Each section includes code examples and explanations in both English and Roman Urdu. It also provides final mastery tips for further learning and offers the option to download the guide as a PDF.

Uploaded by

humayunakbar841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Kotlin Advanced Guide

This document is an advanced guide to the Kotlin programming language, covering topics such as Generics, Annotations, Typealias, Delegation, Reflection, and Domain Specific Language (DSL). Each section includes code examples and explanations in both English and Roman Urdu. It also provides final mastery tips for further learning and offers the option to download the guide as a PDF.

Uploaded by

humayunakbar841
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Kotlin Programming Language - Advanced Guide (Urdu + English)

21. Generics (Flexible Types)

fun <T> display(item: T) {


println(item)
}

display("Hello")
display(123)

Roman Urdu Explanation: Generics se function ya class ko flexible banaya jata hai, jisme kisi bhi type ka
data use ho sakta hai.

22. Annotations (Meta-Information)

@Target([Link])
annotation class Info(val author: String)

@Info("Sanober")
class MyClass

Roman Urdu Explanation: Annotations se classes, methods ya fields ko extra info di ja sakti hai jo tools ya
compiler use karta hai.

23. Typealias (Short Names for Types)

typealias UserList = List<String>


val users: UserList = listOf("Ayesha", "Ali")

Roman Urdu Explanation: typealias se lambay type names ko short aur readable banaya jata hai.

24. Delegation (Reusing Behaviors)

interface Base {
fun print()
}

class BaseImpl(val x: Int) : Base {

1
override fun print() = println(x)
}

class Derived(b: Base) : Base by b

val obj = Derived(BaseImpl(10))


[Link]()

Roman Urdu Explanation: Delegation ka matlab hai doosri class ke function ko reuse karna bina override
kiye.

25. Reflection (Code ko Runtime pe Check Karna)

import [Link]

data class Person(val name: String, val age: Int)

fun main() {
val p = Person("Ali", 25)
val kClass = p::class
for (prop in [Link]) {
println("${[Link]} = ${[Link](p)}")
}
}

Roman Urdu Explanation: Reflection se aap object ya class ke structure ko runtime par analyze kar sakte
hain.

26. DSL (Domain Specific Language)

fun email(block: EmailBuilder.() -> Unit) {


val builder = EmailBuilder()
[Link]()
[Link]()
}

class EmailBuilder {
var to = ""
var message = ""
fun build() = println("Sending email to $to: $message")
}

email {

2
to = "sanober@[Link]"
message = "Welcome to Kotlin DSL!"
}

Roman Urdu Explanation: Kotlin DSL se custom syntax banayi ja sakti hai jo specific task ke liye easy aur
readable hoti hai.

Final Mastery Tips

• Compose navigation + state management seekhein.


• Multiplatform projects explore karein (KMM).
• Android Architecture Components (ViewModel, LiveData, etc.) integrate karein.
• Unit Testing aur UI Testing par focus karein.
• Kotlin blog likhna shuru karein — teaching helps learning!

Agar aap chahein toh is Advanced Guide ko bhi downloadable PDF format mein banaya ja sakta hai. Bataiye
aapko export chahiye?

You might also like