Main: https://en.wikipedia.org/wiki/Kotlin_(programming_language)
Ref: https://medium.com/@mayuroks/learn-kotlin-for-android-in-one-day-50aa0bc099b0
Kotlin has been Google’s preferred language for Android app development since 7 May 2019.
I started working with Kotlin on 7 July 2019. That's 2 months of delay/gap.
I was busy traveling - Tokyo - Seattle - San Francisco - Tokyo - Mumbai - Delhi.
Now that i have settled in one place - Gurgaon, it's time to dive in.
History: Kotlin v1.0 was released on 15 February 2016.
It’s influenced by Java, Scala, Groovy, C#, Gosu, JavaScript, and Swift.
val : constant (immutable)
var : variable (mutable)
var username: String = "some user name"
val API_DELAY_CONSTANT: Int = 100
var myString: String? = null
fun getNumber(): Int {
return 1
}
private fun getStringLength(str1: String, str2: String): Int {
return str1.length + str2.length
}
var items: List<String> = ArrayList<String>()
for (item in items) {
// do something with item
}
for (index in items.indices) {
// access items using index
// items.get(index)
}
var i: Int = 0
// Some while loop
do {
// do something
i++
} while (i < 5)
// Another while loop
while (i < 10) {
// do something
i++
}
// A cool example of when statement
fun describe(obj: Any): String? {
var res: String? = null
when (obj) {
1 -> { res = "One" } // if obj == 1
"Hello" -> res ="Greeting" // if obj == "Hello"
is Long -> "Long" // if obj is of type Long
!is String -> "Not string" // if obj is not of type String
else -> {
// execute this block of code
}
}
return res
}
Kotlin has support for nested functions wow!
All nullable objects must be declared with a "?" postfix after the type name. Operations on nullable objects need special care from developers: null-check must be performed before using the value. Kotlin provides null-safe operators to help developers:
1. A safe navigation operator "?."
2. A null coalescing operator "?:" named Elvis operator after Elvis Presley
Android Studio (based on IntelliJ IDEA) has official support for Kotlin, starting from Android Studio 3.
link: https://developer.android.com/kotlin/index.html
Ref: https://medium.com/@mayuroks/learn-kotlin-for-android-in-one-day-50aa0bc099b0
Kotlin has been Google’s preferred language for Android app development since 7 May 2019.
I started working with Kotlin on 7 July 2019. That's 2 months of delay/gap.
I was busy traveling - Tokyo - Seattle - San Francisco - Tokyo - Mumbai - Delhi.
Now that i have settled in one place - Gurgaon, it's time to dive in.
History: Kotlin v1.0 was released on 15 February 2016.
It’s influenced by Java, Scala, Groovy, C#, Gosu, JavaScript, and Swift.
val : constant (immutable)
var : variable (mutable)
var username: String = "some user name"
val API_DELAY_CONSTANT: Int = 100
var myString: String? = null
fun getNumber(): Int {
return 1
}
private fun getStringLength(str1: String, str2: String): Int {
return str1.length + str2.length
}
var items: List<String> = ArrayList<String>()
for (item in items) {
// do something with item
}
for (index in items.indices) {
// access items using index
// items.get(index)
}
var i: Int = 0
// Some while loop
do {
// do something
i++
} while (i < 5)
// Another while loop
while (i < 10) {
// do something
i++
}
// A cool example of when statement
fun describe(obj: Any): String? {
var res: String? = null
when (obj) {
1 -> { res = "One" } // if obj == 1
"Hello" -> res ="Greeting" // if obj == "Hello"
is Long -> "Long" // if obj is of type Long
!is String -> "Not string" // if obj is not of type String
else -> {
// execute this block of code
}
}
return res
}
Kotlin has support for nested functions wow!
All nullable objects must be declared with a "?" postfix after the type name. Operations on nullable objects need special care from developers: null-check must be performed before using the value. Kotlin provides null-safe operators to help developers:
1. A safe navigation operator "?."
2. A null coalescing operator "?:" named Elvis operator after Elvis Presley
Android Studio (based on IntelliJ IDEA) has official support for Kotlin, starting from Android Studio 3.
link: https://developer.android.com/kotlin/index.html
Apps built with Kotlin:
- Slack
- Lyft
- Robinhood
- Evernote
- Square
- Deliveroo
- Periscope
- Udacity
- Instacart
- Basecamp
- Camera360
- Trello
- Foursquare
- Stride
- Amex
- Expedia
- Netflix
- Kindle
- KeepSafe
- NYTimes
- Wordpress
- Simple Bank
- Airbnb
- Foursquare Robin
- Tencent WeChat
- GoJek
- Confluence
- June
- Adobe Reader
- Zomato
30 minutes to Learn Kotlin : https://developer.android.com/kotlin/learn
Developer Story - Zomato : https://www.youtube.com/watch?v=ao9QvtpszOU