SlideShare a Scribd company logo
1 of 17
Who am I?
 Corneliu Balaban
 Mobile Engineering Manager @ Avira Romania
 Android aficionado with BI background
 Catching up on the “Kotlin for iOS” – Swift
 Passionate about BioMedical and AgriTech
What is this …
Kotlin?
 It is a Russian Island close
to St. Petersburg
 Initially belong to Sweden
but after Russia annexed it
and …
 Inspired the name for a new
programming language
running in the JVM
 Created by JetBrains,
creators of PhpStorm,
WebStorm, PyCharm etc
 Ads small overhead to the
Android dev env and dex
method count increase by
~6k methods
What have we
been missing
inJava?
 No need for functional interfaces in order to implement own
higher functions and lambda’s
 Embedded lists iterators and mapping functions
 Class extensions (well… Swift has them)
 Strongly typed with inferred data types
 No elegant ways of avoiding NPE’s
Basic Kotlin
syntax
fun sayHello(name: String): Unit {
print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup");
}
OR
fun sayHello(name: String): Unit = print("Hello ${name}!" + "Welcome to Bucharest
Mobile Meetup");
OR
fun sayHello(name: String) = print("Hello ${name}!" + "Welcome to Bucharest
Mobile Meetup");
OOP concepts
Kotlin classes
 Inherit from Java’s equivalent of Object  Any
 By default are final
 Inheritance is enabled by prefixing the class with "open"
 Primary constructor is embedded in the class signature . It cannot
contain any code
 Secondary constructors are available. Need to delegate to primary
constructor
 init() methods come to the rescue
 Immutable variables are represented by the prefix "val" and can have
inferred data type
OOP concepts
Good ol' "bean"
 Easily accessible via "data classes"
 Makes a good separation of code if you want some objects that just
need to hold data
 Can make use of companion objects to hold “static” values
MoreOOP …
 Java developers love to be "static"
 Bad luck, there are no class level methods
 "Companion objects" are the new black
 Used to replicate "statics" behavior in Kotlin
 Can be one per class
 Static variables are not available other than via " companion
objects
var, val … do I
need to know
them?
 Immutable objects/ variables are prefixed with "val"
 Can be initialized at declaration time. No data type needed as
inference works as a charm
 If they cannot be initialized at declaration time then data type is
mandatory
 Are there other kinds of immutable objects?
 var toDoList1: List<ToDoModel> = listOf(ToDoModel(name="Buy
Milk"),ToDoModel(name="Buy Weed"));
• var toDoList: MutableList<ToDoModel> = mutableListOf()
If val reffers to
immutable, do
I have project
level constants
 Compile time constants are defined using
the prefix "const”
 Cannot have a custom getter
 Can be used in annotations
 Can only be of type String or another
primitive
 Can or cannot be part of a class/ object
 Immutable and mutable properties have intrinsic get and set methods
 You can customize the visibility of the setter and or getter as well as their
behavior
 Since properties need to be assigned values at compile time, the only
way to define properties that can receive runtime values is by using the
prefix "lateinit"
Optionals &
null safe
accessors
 Swift has them so why not Kotlin as well
 They are some weird implementation of Schroedingers cat
 Optional properties can contain a value or can be null
 Methods can return optionals as well
• To access potentially null variables/ objects you
can use ?.
• In chaining if at least one of the conditions
is null then the entire chained expression is
null
Loops,
operator
overloading
and string
interpolation
 Iterating collections is easier with " for – in " loops . No more of the
Java " for – each" nightmare
 Range loops are introduces to help us run code for exact number
of times " for i in 1 .. 27"
 Operator overloading has been made available yet by another
language running on top on the JVM ( as did Groovy)
 String templates and interpolations are yet another valuable
Lambdas and
higher order
functions
 Introduced in Java 8 but cumbersome to use.Why?
 Cumbersome to introduce as functional interfaces are needed
 Not backwards compatible
 Not really useful for Android developers as we are still stuck on Java
7
 Lambdas are natively supported by Kotlin
 Kotlin allows methods that can receive other functions as
parameters
 Also it allows the existence of functions outside classes which is
perfect for utils
Extensions
 Imagine that "String" would have an … ”getGreetingById" method
 Extensions can be used to add custom methods to existing objects
 They can be called as : Object. getGreetingById(1)
 Very similar to Swift extensions
Useful
resources
 Must try the "anko" library: https://github.com/Kotlin/anko
 Get dirty with Kotlin Koans here:
http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Strings/T
ask.kt
 Try reading Antonio Leiva's Kotlin book:
https://leanpub.com/kotlin-for-android-developers
Oh, and one
more thing …
adding Kotlin
to your project
 Not going through all the steps ;)
 Check them here:
https://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin-in-
android-studio/
Q &A

More Related Content

What's hot

What's hot (20)

Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
 
Introduction to kotlin
Introduction to kotlinIntroduction to kotlin
Introduction to kotlin
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
 
Why I ❤️ Kotlin Multiplatform (and want YOU to also ❤️ Kotlin Multiplatform)
Why I ❤️ Kotlin Multiplatform (and want YOU to also ❤️ Kotlin Multiplatform)Why I ❤️ Kotlin Multiplatform (and want YOU to also ❤️ Kotlin Multiplatform)
Why I ❤️ Kotlin Multiplatform (and want YOU to also ❤️ Kotlin Multiplatform)
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
Introduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in KotlinIntroduction to kotlin and OOP in Kotlin
Introduction to kotlin and OOP in Kotlin
 
Android IPC Mechanism
Android IPC MechanismAndroid IPC Mechanism
Android IPC Mechanism
 
Java basic
Java basicJava basic
Java basic
 
Kotlin Multiplatform
Kotlin MultiplatformKotlin Multiplatform
Kotlin Multiplatform
 
Flutter workshop
Flutter workshopFlutter workshop
Flutter workshop
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 

Viewers also liked

Introduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clearIntroduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clear
Andrey Breslav
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
Bartosz Kosarzycki
 

Viewers also liked (6)

Intro to kotlin
Intro to kotlinIntro to kotlin
Intro to kotlin
 
Introduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clearIntroduction to Kotlin: Brief and clear
Introduction to Kotlin: Brief and clear
 
Kotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developersKotlin advanced - language reference for android developers
Kotlin advanced - language reference for android developers
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
PPT - Powerful Presentation Techniques
PPT - Powerful Presentation TechniquesPPT - Powerful Presentation Techniques
PPT - Powerful Presentation Techniques
 
Slideshare ppt
Slideshare pptSlideshare ppt
Slideshare ppt
 

Similar to Kotlin presentation

Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
Havoc Pennington
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigerians
junaidhasan17
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
elliando dias
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
YLTO
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
BalamuruganV28
 

Similar to Kotlin presentation (20)

JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Dear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans tooDear Kotliners - Java Developers are Humans too
Dear Kotliners - Java Developers are Humans too
 
Kotlin from-scratch
Kotlin from-scratchKotlin from-scratch
Kotlin from-scratch
 
Scala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on HerokuScala, Akka, and Play: An Introduction on Heroku
Scala, Akka, and Play: An Introduction on Heroku
 
scala-intro
scala-introscala-intro
scala-intro
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
Kotlin  what_you_need_to_know-converted event 4 with nigeriansKotlin  what_you_need_to_know-converted event 4 with nigerians
Kotlin what_you_need_to_know-converted event 4 with nigerians
 
Clojure and The Robot Apocalypse
Clojure and The Robot ApocalypseClojure and The Robot Apocalypse
Clojure and The Robot Apocalypse
 
Java Closures
Java ClosuresJava Closures
Java Closures
 
Scala for n00bs by a n00b.
Scala for n00bs by a n00b.Scala for n00bs by a n00b.
Scala for n00bs by a n00b.
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1
 
Scala final ppt vinay
Scala final ppt vinayScala final ppt vinay
Scala final ppt vinay
 
Introduction to Kotlin for Android developers
Introduction to Kotlin for Android developersIntroduction to Kotlin for Android developers
Introduction to Kotlin for Android developers
 
Kevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScriptKevin Whinnery: Write Better JavaScript
Kevin Whinnery: Write Better JavaScript
 
Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014 Top 10 Java Interview Questions and Answers 2014
Top 10 Java Interview Questions and Answers 2014
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Scala the-good-parts
Scala the-good-partsScala the-good-parts
Scala the-good-parts
 
Scala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologistScala and jvm_languages_praveen_technologist
Scala and jvm_languages_praveen_technologist
 
Object Oriented Programming All Unit Notes
Object Oriented Programming All Unit NotesObject Oriented Programming All Unit Notes
Object Oriented Programming All Unit Notes
 
Kotlin at Team Billing
Kotlin at Team BillingKotlin at Team Billing
Kotlin at Team Billing
 
Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021Projects Valhalla and Loom at IT Tage 2021
Projects Valhalla and Loom at IT Tage 2021
 

More from MobileAcademy

More from MobileAcademy (10)

Questo presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup BucharestQuesto presentation @ mobile growth meetup Bucharest
Questo presentation @ mobile growth meetup Bucharest
 
Ludicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup RomaniaLudicon presentation @ mobile growth meetup Romania
Ludicon presentation @ mobile growth meetup Romania
 
Push notifications at scale
Push notifications at scalePush notifications at scale
Push notifications at scale
 
MVVM with RxJava
MVVM with RxJavaMVVM with RxJava
MVVM with RxJava
 
Kotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRreadyKotlin for Android - Vali Iorgu - mRready
Kotlin for Android - Vali Iorgu - mRready
 
Azure for Android Developers
Azure for Android Developers Azure for Android Developers
Azure for Android Developers
 
"Inspectorul Padurii" mobile app - Bogdan Micu
 "Inspectorul Padurii" mobile app - Bogdan Micu "Inspectorul Padurii" mobile app - Bogdan Micu
"Inspectorul Padurii" mobile app - Bogdan Micu
 
Madalina Seghete, Branch Metrics, presentation on app virality
Madalina Seghete, Branch Metrics, presentation on  app viralityMadalina Seghete, Branch Metrics, presentation on  app virality
Madalina Seghete, Branch Metrics, presentation on app virality
 
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform developmentRares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
Rares Serban, Sr. Mobile Developer at Soft to you - cross-platform development
 
Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2Bucharest City App presentation @MobileAcademy Meetup #2
Bucharest City App presentation @MobileAcademy Meetup #2
 

Recently uploaded

Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Recently uploaded (20)

tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 

Kotlin presentation

  • 1.
  • 2. Who am I?  Corneliu Balaban  Mobile Engineering Manager @ Avira Romania  Android aficionado with BI background  Catching up on the “Kotlin for iOS” – Swift  Passionate about BioMedical and AgriTech
  • 3. What is this … Kotlin?  It is a Russian Island close to St. Petersburg  Initially belong to Sweden but after Russia annexed it and …  Inspired the name for a new programming language running in the JVM  Created by JetBrains, creators of PhpStorm, WebStorm, PyCharm etc  Ads small overhead to the Android dev env and dex method count increase by ~6k methods
  • 4. What have we been missing inJava?  No need for functional interfaces in order to implement own higher functions and lambda’s  Embedded lists iterators and mapping functions  Class extensions (well… Swift has them)  Strongly typed with inferred data types  No elegant ways of avoiding NPE’s
  • 5. Basic Kotlin syntax fun sayHello(name: String): Unit { print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup"); } OR fun sayHello(name: String): Unit = print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup"); OR fun sayHello(name: String) = print("Hello ${name}!" + "Welcome to Bucharest Mobile Meetup");
  • 6. OOP concepts Kotlin classes  Inherit from Java’s equivalent of Object  Any  By default are final  Inheritance is enabled by prefixing the class with "open"  Primary constructor is embedded in the class signature . It cannot contain any code  Secondary constructors are available. Need to delegate to primary constructor  init() methods come to the rescue  Immutable variables are represented by the prefix "val" and can have inferred data type
  • 7. OOP concepts Good ol' "bean"  Easily accessible via "data classes"  Makes a good separation of code if you want some objects that just need to hold data  Can make use of companion objects to hold “static” values
  • 8. MoreOOP …  Java developers love to be "static"  Bad luck, there are no class level methods  "Companion objects" are the new black  Used to replicate "statics" behavior in Kotlin  Can be one per class  Static variables are not available other than via " companion objects
  • 9. var, val … do I need to know them?  Immutable objects/ variables are prefixed with "val"  Can be initialized at declaration time. No data type needed as inference works as a charm  If they cannot be initialized at declaration time then data type is mandatory  Are there other kinds of immutable objects?  var toDoList1: List<ToDoModel> = listOf(ToDoModel(name="Buy Milk"),ToDoModel(name="Buy Weed")); • var toDoList: MutableList<ToDoModel> = mutableListOf()
  • 10. If val reffers to immutable, do I have project level constants  Compile time constants are defined using the prefix "const”  Cannot have a custom getter  Can be used in annotations  Can only be of type String or another primitive  Can or cannot be part of a class/ object  Immutable and mutable properties have intrinsic get and set methods  You can customize the visibility of the setter and or getter as well as their behavior  Since properties need to be assigned values at compile time, the only way to define properties that can receive runtime values is by using the prefix "lateinit"
  • 11. Optionals & null safe accessors  Swift has them so why not Kotlin as well  They are some weird implementation of Schroedingers cat  Optional properties can contain a value or can be null  Methods can return optionals as well • To access potentially null variables/ objects you can use ?. • In chaining if at least one of the conditions is null then the entire chained expression is null
  • 12. Loops, operator overloading and string interpolation  Iterating collections is easier with " for – in " loops . No more of the Java " for – each" nightmare  Range loops are introduces to help us run code for exact number of times " for i in 1 .. 27"  Operator overloading has been made available yet by another language running on top on the JVM ( as did Groovy)  String templates and interpolations are yet another valuable
  • 13. Lambdas and higher order functions  Introduced in Java 8 but cumbersome to use.Why?  Cumbersome to introduce as functional interfaces are needed  Not backwards compatible  Not really useful for Android developers as we are still stuck on Java 7  Lambdas are natively supported by Kotlin  Kotlin allows methods that can receive other functions as parameters  Also it allows the existence of functions outside classes which is perfect for utils
  • 14. Extensions  Imagine that "String" would have an … ”getGreetingById" method  Extensions can be used to add custom methods to existing objects  They can be called as : Object. getGreetingById(1)  Very similar to Swift extensions
  • 15. Useful resources  Must try the "anko" library: https://github.com/Kotlin/anko  Get dirty with Kotlin Koans here: http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Strings/T ask.kt  Try reading Antonio Leiva's Kotlin book: https://leanpub.com/kotlin-for-android-developers
  • 16. Oh, and one more thing … adding Kotlin to your project  Not going through all the steps ;)  Check them here: https://blog.jetbrains.com/kotlin/2013/08/working-with-kotlin-in- android-studio/
  • 17. Q &A