SlideShare a Scribd company logo
1 of 16
July
2018
Robert MacLean
@rmaclean
3
Robert MacLean
@rmaclean
SADEV.co.za
4
Basic
Pascal
Delphi
PHP
Perl
C#
JavaScript
TypeScript
Java
Kotlin
C#
5
Kotlin
var name = "";
...
if (name != null) {
}
var member = existing ?? new Person();
var name = ""
name = null // NOPE!
var name : String? = ""
var member = existing ?: Person()
C#
6
Kotlin
var person = new Person();
...
if (person?.name != null) {
}
var person? = Person()
...
if (person?.name != null) {
}
var s : String? = null
println(s.length) // won’t compile
println(s?.length) // null
println(s!!.length) // NPE
JavaScript
7
Kotlin
let numbers = [1, 5, 6, 7, 8];
let evens = numbers
.filter(num => num % 2 === 0);
val numbers = listOf(1, 5, 6, 7, 8)
var evens = numbers
.filter({ num -> num % 2 == 0 })
evens = numbers.filter({ it % 2 == 0 })
Java
8
Kotlin
foo.is(bar)
public void should_have_visible_logout() {
}
foo.`is`(bar)
fun `should have visible logout`() {
}
C#
9
Kotlin
throw new Exception();
// compiler will tell you this won’t
execute
void start() {
while (true) {
...
}
}
start();
// compiler totally happy
fun start():Nothing {
while (true) {
...
}
}
start()
// compiler will tell you this won’t
execute onwards!
Java
10
Kotlin
public class Person {
private String name;
private int age = 0;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
if (name != null ? !name.equals(person.name) : person.name != null) return false;
if (age != 0 ? age != person.age : person.age != 0) return false;
}
@Override
public int hashCode() {
public class Person {
private String name;
private int age = 0;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
if (name != null ? !name.equals(person.name) : person.name != null) return
false;
if (age != 0 ? age != person.age : person.age != 0) return false;
}
@Override
public int hashCode() {
int result = name != null ? name.hashCode() : 0;
result = 31 * result + age;
return result;
}
@Override
public String toString() {
return "Person{" +
"name='" + name + ''' +
", age='" + age + ''' +
'}';
}
}
C#
12
Kotlin
class Person
{
public int Age {get; set;}
public string Name {get; set;}
public Person(int Age, string Name){
this.Age = Age;
this.Name = Name;
}
}
Java
13
Kotlin
public class Person {
private String name;
private int age = 0;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Person person = (Person) o;
if (name != null ? !name.equals(person.name) : person.name != null) return false;
if (age != 0 ? age != person.age : person.age != 0) return false;
}
@Override
public int hashCode() {
data class User(val name: String, val age: Int)
14
Kotlin 101
29 August
CodeBridge in Newlands
http://bit.ly/kotlin101
15
ExpertDrinks
2 August
http://bit.ly/expertdrinks
Robert MacLean
Twitter
@rmaclean
Web
sadev.co.za
16

More Related Content

What's hot

Expression trees in c#
Expression trees in c#Expression trees in c#
Expression trees in c#Oleksii Holub
 
Lambdas and Generics (long version) - Bordeaux/Toulouse JUG
Lambdas and Generics (long version) - Bordeaux/Toulouse JUGLambdas and Generics (long version) - Bordeaux/Toulouse JUG
Lambdas and Generics (long version) - Bordeaux/Toulouse JUGHenri Tremblay
 
Kotlin Lambda
Kotlin LambdaKotlin Lambda
Kotlin LambdaLutasLin
 
Let's fly to the Kotlin Island. Just an introduction to Kotlin
Let's fly to the Kotlin Island. Just an introduction to KotlinLet's fly to the Kotlin Island. Just an introduction to Kotlin
Let's fly to the Kotlin Island. Just an introduction to KotlinAliaksei Zhynhiarouski
 
Expression trees in c#, Алексей Голубь (Svitla Systems)
Expression trees in c#, Алексей Голубь (Svitla Systems)Expression trees in c#, Алексей Голубь (Svitla Systems)
Expression trees in c#, Алексей Голубь (Svitla Systems)Alina Vilk
 

What's hot (6)

Expression trees in c#
Expression trees in c#Expression trees in c#
Expression trees in c#
 
Lambdas and Generics (long version) - Bordeaux/Toulouse JUG
Lambdas and Generics (long version) - Bordeaux/Toulouse JUGLambdas and Generics (long version) - Bordeaux/Toulouse JUG
Lambdas and Generics (long version) - Bordeaux/Toulouse JUG
 
Kotlin Lambda
Kotlin LambdaKotlin Lambda
Kotlin Lambda
 
Let's fly to the Kotlin Island. Just an introduction to Kotlin
Let's fly to the Kotlin Island. Just an introduction to KotlinLet's fly to the Kotlin Island. Just an introduction to Kotlin
Let's fly to the Kotlin Island. Just an introduction to Kotlin
 
Expression trees in c#, Алексей Голубь (Svitla Systems)
Expression trees in c#, Алексей Голубь (Svitla Systems)Expression trees in c#, Алексей Голубь (Svitla Systems)
Expression trees in c#, Алексей Голубь (Svitla Systems)
 
Why Kotlin is your next language?
Why Kotlin is your next language? Why Kotlin is your next language?
Why Kotlin is your next language?
 

Similar to Features of Kotlin I find exciting

Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective JavaScalac
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to KotlinShine Joseph
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodecamp Romania
 
BEKK Teknologiradar - Kotlin
BEKK Teknologiradar - KotlinBEKK Teknologiradar - Kotlin
BEKK Teknologiradar - KotlinVegard Veiset
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFabio Collini
 
5 Bullets to Scala Adoption
5 Bullets to Scala Adoption5 Bullets to Scala Adoption
5 Bullets to Scala AdoptionTomer Gabel
 
Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Paulo Morgado
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlinThijs Suijten
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldBTI360
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116Paulo Morgado
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlinThijs Suijten
 
Kotlin : Happy Development
Kotlin : Happy DevelopmentKotlin : Happy Development
Kotlin : Happy DevelopmentMd Sazzad Islam
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokusHamletDRC
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Andrey Akinshin
 
1.1 motivation
1.1 motivation1.1 motivation
1.1 motivationwpgreenway
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Codemotion
 

Similar to Features of Kotlin I find exciting (20)

Unleashing kotlin's power
Unleashing kotlin's powerUnleashing kotlin's power
Unleashing kotlin's power
 
Scala == Effective Java
Scala == Effective JavaScala == Effective Java
Scala == Effective Java
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
BEKK Teknologiradar - Kotlin
BEKK Teknologiradar - KotlinBEKK Teknologiradar - Kotlin
BEKK Teknologiradar - Kotlin
 
Scala introduction
Scala introductionScala introduction
Scala introduction
 
From java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+kFrom java to kotlin beyond alt+shift+cmd+k
From java to kotlin beyond alt+shift+cmd+k
 
5 Bullets to Scala Adoption
5 Bullets to Scala Adoption5 Bullets to Scala Adoption
5 Bullets to Scala Adoption
 
Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6Tuga it 2016 - What's New In C# 6
Tuga it 2016 - What's New In C# 6
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
Pure kotlin
Pure kotlinPure kotlin
Pure kotlin
 
Scala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 WorldScala vs Java 8 in a Java 8 World
Scala vs Java 8 in a Java 8 World
 
What's new in C# 6 - NetPonto Porto 20160116
What's new in C# 6  - NetPonto Porto 20160116What's new in C# 6  - NetPonto Porto 20160116
What's new in C# 6 - NetPonto Porto 20160116
 
No excuses, switch to kotlin
No excuses, switch to kotlinNo excuses, switch to kotlin
No excuses, switch to kotlin
 
1.1 motivation
1.1 motivation1.1 motivation
1.1 motivation
 
Kotlin : Happy Development
Kotlin : Happy DevelopmentKotlin : Happy Development
Kotlin : Happy Development
 
AST Transformations at JFokus
AST Transformations at JFokusAST Transformations at JFokus
AST Transformations at JFokus
 
Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?Что нам готовит грядущий C#7?
Что нам готовит грядущий C#7?
 
1.1 motivation
1.1 motivation1.1 motivation
1.1 motivation
 
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
Kotlin for Android Developers - Victor Kropp - Codemotion Rome 2018
 

More from Robert MacLean

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)Robert MacLean
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPRobert MacLean
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival GuideRobert MacLean
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ MicrosoftRobert MacLean
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptRobert MacLean
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestRobert MacLean
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban Robert MacLean
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersRobert MacLean
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainerRobert MacLean
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budgetRobert MacLean
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONGRobert MacLean
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesRobert MacLean
 

More from Robert MacLean (20)

14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)14 things you need to be a successful software developer (v3)
14 things you need to be a successful software developer (v3)
 
Git
GitGit
Git
 
OWASP TOP 10
OWASP TOP 10OWASP TOP 10
OWASP TOP 10
 
Building a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCPBuilding a µservice with Kotlin, Micronaut & GCP
Building a µservice with Kotlin, Micronaut & GCP
 
Looking at the Vue
Looking at the VueLooking at the Vue
Looking at the Vue
 
Kotlin 101
Kotlin 101Kotlin 101
Kotlin 101
 
JavaScript Gotchas
JavaScript GotchasJavaScript Gotchas
JavaScript Gotchas
 
DevConf Survival Guide
DevConf Survival GuideDevConf Survival Guide
DevConf Survival Guide
 
The state of testing @ Microsoft
The state of testing @ MicrosoftThe state of testing @ Microsoft
The state of testing @ Microsoft
 
Visual Studio ❤ JavaScript
Visual Studio ❤ JavaScriptVisual Studio ❤ JavaScript
Visual Studio ❤ JavaScript
 
What is new in C# 6?
What is new in C# 6?What is new in C# 6?
What is new in C# 6?
 
Putting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/TestPutting the DOT in .NET - Dev/Ops/Test
Putting the DOT in .NET - Dev/Ops/Test
 
A Developer Day 2014 - Durban
A Developer Day 2014 - Durban A Developer Day 2014 - Durban
A Developer Day 2014 - Durban
 
Agile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM RangersAgile lessons learned in the Microsoft ALM Rangers
Agile lessons learned in the Microsoft ALM Rangers
 
Hour of code - Train the trainer
Hour of code - Train the trainerHour of code - Train the trainer
Hour of code - Train the trainer
 
Building services for apps on a shoestring budget
Building services for apps on a shoestring budgetBuilding services for apps on a shoestring budget
Building services for apps on a shoestring budget
 
3 things your app API is doing WRONG
3 things your app API is doing WRONG3 things your app API is doing WRONG
3 things your app API is doing WRONG
 
ASP.NET
ASP.NETASP.NET
ASP.NET
 
LightSwitch
LightSwitchLightSwitch
LightSwitch
 
How to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutesHow to build a Mobile API or HTML 5 app in 5 minutes
How to build a Mobile API or HTML 5 app in 5 minutes
 

Recently uploaded

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 

Recently uploaded (20)

WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 

Features of Kotlin I find exciting

  • 1.
  • 5. C# 5 Kotlin var name = ""; ... if (name != null) { } var member = existing ?? new Person(); var name = "" name = null // NOPE! var name : String? = "" var member = existing ?: Person()
  • 6. C# 6 Kotlin var person = new Person(); ... if (person?.name != null) { } var person? = Person() ... if (person?.name != null) { } var s : String? = null println(s.length) // won’t compile println(s?.length) // null println(s!!.length) // NPE
  • 7. JavaScript 7 Kotlin let numbers = [1, 5, 6, 7, 8]; let evens = numbers .filter(num => num % 2 === 0); val numbers = listOf(1, 5, 6, 7, 8) var evens = numbers .filter({ num -> num % 2 == 0 }) evens = numbers.filter({ it % 2 == 0 })
  • 8. Java 8 Kotlin foo.is(bar) public void should_have_visible_logout() { } foo.`is`(bar) fun `should have visible logout`() { }
  • 9. C# 9 Kotlin throw new Exception(); // compiler will tell you this won’t execute void start() { while (true) { ... } } start(); // compiler totally happy fun start():Nothing { while (true) { ... } } start() // compiler will tell you this won’t execute onwards!
  • 10. Java 10 Kotlin public class Person { private String name; private int age = 0; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; if (name != null ? !name.equals(person.name) : person.name != null) return false; if (age != 0 ? age != person.age : person.age != 0) return false; } @Override public int hashCode() {
  • 11. public class Person { private String name; private int age = 0; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; if (name != null ? !name.equals(person.name) : person.name != null) return false; if (age != 0 ? age != person.age : person.age != 0) return false; } @Override public int hashCode() { int result = name != null ? name.hashCode() : 0; result = 31 * result + age; return result; } @Override public String toString() { return "Person{" + "name='" + name + ''' + ", age='" + age + ''' + '}'; } }
  • 12. C# 12 Kotlin class Person { public int Age {get; set;} public string Name {get; set;} public Person(int Age, string Name){ this.Age = Age; this.Name = Name; } }
  • 13. Java 13 Kotlin public class Person { private String name; private int age = 0; public Person(String name, int age) { this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; if (name != null ? !name.equals(person.name) : person.name != null) return false; if (age != 0 ? age != person.age : person.age != 0) return false; } @Override public int hashCode() { data class User(val name: String, val age: Int)
  • 14. 14 Kotlin 101 29 August CodeBridge in Newlands http://bit.ly/kotlin101