Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Statically typed programming language
for the JVM, Android and the browser
100% interoperable with Java™
PaymentRobot payment = new PaymentRobot();
ResultRobot result = payment
.amount(42_00)
.recipient("foo@bar.com")
.send();
...
val payment = PaymentRobot()
val result = payment
.amount(4200)
.recipient("foo@bar.com")
.send()
result.isSuccess()
val result = payment {
amount(4200)
recipient("foo@bar.com")
}.send()
result.isSuccess()
payment {
amount(4200)
recipient("foo@bar.com")
}.send {
isSuccess()
}
payment {
amount(4200)
recipient("foo@bar.com")
} send {
isSuccess()
}
payment {
amount(4200)
recipient("foo@bar.com")
send()
}
birthday {
date(1970, 1, 1)
next()
}
ssn {
value("123-56-7890")
n...
public String foo() {

...

}
// null or non-null?

String f = foo();
@NonNull
public String foo() {

...

}
// non-null

String f = foo();
// nullable

fun nullable(): String? {

...

}



// non-null

fun nonNull(): String {

...

}
// ok

val foo: String? = "foo"



// compile error

val bar: String = null
String foo = "foo";

String bar = "foo";

// isEquals: true
boolean isEquals = foo.equals(bar);
String foo = "foo";

String bar = "foo";



// isEquals: false
boolean isEquals = foo == bar;
val foo = "foo"

val bar = "bar"



// isEquals: true
val isEquals = foo == bar
// MyFunctions.kt



package com.sample.package



fun foo() { }
// OtherFunctions.kt

package com.sample.package.others

// import function foo()

import com.sample.package.foo



fun ba...
public class MainActivity extends AppCompatActivity {



Button btnCalligraphy;



@Override

protected void onCreate(Bund...
class MainActivity : AppCompatActivity() {



override fun onCreate(savedInstanceState: Bundle?) {

super.onCreate(savedIn...
view.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View v) {

Toast.makeText(
v.getConte...
view.setOnClickListener({ v ->



Toast.makeText(v.context.applicationContext,

"Hello", Toast.LENGTH_SHORT).show()



})
view.setOnClickListener { v ->



Toast.makeText(v.context.applicationContext,

"Hello", Toast.LENGTH_SHORT).show()



}
view.setOnClickListener {



Toast.makeText(it.context.applicationContext,

"Hello", Toast.LENGTH_SHORT).show()



}
val people : List<String> = ..


people.filter { it.startsWith('S') }

.filter { it.length < 10 }

.onEach { it.toUpperCas...
val people : List<String> = ..


people.filter { it.startsWith('S') }

.filter { it.length < 10 }

.onEach(String::toUpper...
val people : List<String> = ..


people.stream()

.filter { it.startsWith('S') }

.filter { it.length < 10 }

.map(String:...
var foo : String = "Foo"

foo = "FOO"



val bar : String = "Bar"

bar = "BAR"
var foo : String = "Foo"

foo = "FOO"



val bar : String = "Bar"

bar = "BAR"
Compile Error (val cannot be reassigned)
val mutableList : MutableList<String>
= mutableListOf(“foo", "bar", "baz")

mutableList.add("fizz")



val immutableList :...
val mutableList : MutableList<String>
= mutableListOf("foo", "bar", "baz")

mutableList.add("fizz")



val immutableList :...
val emptyStringList = listOf<String>()



val cities = listOf("Seoul", "Busan")



val mutableCities = mutableListOf("Seou...
val emptyStringSet = setOf<String>()



val cities = setOf("Seoul", "Busan")



val mutableCities = mutableSetOf("Seoul, B...
val pair : Pair<String, String> = Pair("Seoul", "서울")
val pair : Pair<String, String> = "Seoul" to "서울"
public class Person {



String name;



String address;



Person(String name, String address) {

this.name = name;

this...
public class Person {



String name;



String address;



Person(String name, String address) {

this.name = name;

this...
data class Person(val name: String, val address: String)
Toast.makeText(applicationContext,
"Hello, Kotlin!", Toast.LENGTH_SHORT).show()
// Define an extension function on Context
fun Context.toast(message: String) {

Toast.makeText(this.applicationContext,
m...
Happy Kotlin!
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
레진코믹스가 코틀린으로 간 까닭은?
Upcoming SlideShare
Loading in …5
×

레진코믹스가 코틀린으로 간 까닭은?

10,305 views

Published on

레진코믹스 안드로이드 앱은 왜 코틀린을 쓰게 된 것일까요? 그 이유와 함께, 코틀린을 도입하면서 겪은 경험담과 팁을 공유합니다.

Kotlin Night Seoul 2017
2017.4.12

Published in: Software
  • Be the first to comment

레진코믹스가 코틀린으로 간 까닭은?

  1. 1. Statically typed programming language for the JVM, Android and the browser 100% interoperable with Java™
  2. 2. PaymentRobot payment = new PaymentRobot(); ResultRobot result = payment .amount(42_00) .recipient("foo@bar.com") .send(); result.isSuccess();
  3. 3. val payment = PaymentRobot() val result = payment .amount(4200) .recipient("foo@bar.com") .send() result.isSuccess()
  4. 4. val result = payment { amount(4200) recipient("foo@bar.com") }.send() result.isSuccess()
  5. 5. payment { amount(4200) recipient("foo@bar.com") }.send { isSuccess() }
  6. 6. payment { amount(4200) recipient("foo@bar.com") } send { isSuccess() }
  7. 7. payment { amount(4200) recipient("foo@bar.com") send() } birthday { date(1970, 1, 1) next() } ssn { value("123-56-7890") next() } result { isSuccess() }
  8. 8. public String foo() {
 ...
 } // null or non-null?
 String f = foo();
  9. 9. @NonNull public String foo() {
 ...
 } // non-null
 String f = foo();
  10. 10. // nullable
 fun nullable(): String? {
 ...
 }
 
 // non-null
 fun nonNull(): String {
 ...
 }
  11. 11. // ok
 val foo: String? = "foo"
 
 // compile error
 val bar: String = null
  12. 12. String foo = "foo";
 String bar = "foo";
 // isEquals: true boolean isEquals = foo.equals(bar);
  13. 13. String foo = "foo";
 String bar = "foo";
 
 // isEquals: false boolean isEquals = foo == bar;
  14. 14. val foo = "foo"
 val bar = "bar"
 
 // isEquals: true val isEquals = foo == bar
  15. 15. // MyFunctions.kt
 
 package com.sample.package
 
 fun foo() { }
  16. 16. // OtherFunctions.kt
 package com.sample.package.others
 // import function foo()
 import com.sample.package.foo
 
 fun baz() {
 foo()
 }
  17. 17. public class MainActivity extends AppCompatActivity {
 
 Button btnCalligraphy;
 
 @Override
 protected void onCreate(Bundle savedInstanceState) {
 super.onCreate(savedInstanceState);
 setContentView(R.layout.activity_main);
 
 btnCalligraphy = (Button) findViewById(R.id.btn_calligraphy);
 
 btnCalligraphy.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View view) {
 // Do something
 }
 });
 
 }
 }
  18. 18. class MainActivity : AppCompatActivity() {
 
 override fun onCreate(savedInstanceState: Bundle?) {
 super.onCreate(savedInstanceState)
 setContentView(R.layout.activity_main)
 
 btn_calligraphy.setOnClickListener {
 // Do something
 }
 }
 }
  19. 19. view.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View v) {
 Toast.makeText( v.getContext().getApplicationContext(),
 "Hello", Toast.LENGTH_SHORT).show();
 }
 });
  20. 20. view.setOnClickListener({ v ->
 
 Toast.makeText(v.context.applicationContext,
 "Hello", Toast.LENGTH_SHORT).show()
 
 })
  21. 21. view.setOnClickListener { v ->
 
 Toast.makeText(v.context.applicationContext,
 "Hello", Toast.LENGTH_SHORT).show()
 
 }
  22. 22. view.setOnClickListener {
 
 Toast.makeText(it.context.applicationContext,
 "Hello", Toast.LENGTH_SHORT).show()
 
 }
  23. 23. val people : List<String> = .. 
 people.filter { it.startsWith('S') }
 .filter { it.length < 10 }
 .onEach { it.toUpperCase() }
 .forEach { println(it) }
  24. 24. val people : List<String> = .. 
 people.filter { it.startsWith('S') }
 .filter { it.length < 10 }
 .onEach(String::toUpperCase)
 .forEach(::println)
  25. 25. val people : List<String> = .. 
 people.stream()
 .filter { it.startsWith('S') }
 .filter { it.length < 10 }
 .map(String::toUpperCase)
 .forEach(::println)
  26. 26. var foo : String = "Foo"
 foo = "FOO"
 
 val bar : String = "Bar"
 bar = "BAR"
  27. 27. var foo : String = "Foo"
 foo = "FOO"
 
 val bar : String = "Bar"
 bar = "BAR" Compile Error (val cannot be reassigned)
  28. 28. val mutableList : MutableList<String> = mutableListOf(“foo", "bar", "baz")
 mutableList.add("fizz")
 
 val immutableList : List<String> = listOf("foo", "bar", "baz")
 immutableList.add("fizz")
  29. 29. val mutableList : MutableList<String> = mutableListOf("foo", "bar", "baz")
 mutableList.add("fizz")
 
 val immutableList : List<String> = listOf("foo", "bar", "baz")
 immutableList.add("fizz") Compile Error (val cannot be reassigned)
  30. 30. val emptyStringList = listOf<String>()
 
 val cities = listOf("Seoul", "Busan")
 
 val mutableCities = mutableListOf("Seoul, Busan")
  31. 31. val emptyStringSet = setOf<String>()
 
 val cities = setOf("Seoul", "Busan")
 
 val mutableCities = mutableSetOf("Seoul, Busan")
  32. 32. val pair : Pair<String, String> = Pair("Seoul", "서울")
  33. 33. val pair : Pair<String, String> = "Seoul" to "서울"
  34. 34. public class Person {
 
 String name;
 
 String address;
 
 Person(String name, String address) {
 this.name = name;
 this.address = address;
 }
 
 public String getAddress() {
 return address;
 }
 
 public void setAddress(String address) {
 this.address = address;
 }
 }
  35. 35. public class Person {
 
 String name;
 
 String address;
 
 Person(String name, String address) {
 this.name = name;
 this.address = address;
 }
 
 public String getAddress() {
 return address;
 }
 
 public void setAddress(String address) {
 this.address = address;
 }
 
 @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.equals(person.name)) {
 return false;
 }
 return address != null ? address.equals(person.address) : person.address == null;
 
 }
 
 @Override
 public int hashCode() {
 int result = name.hashCode();
 result = 31 * result + (address != null ? address.hashCode() : 0);
 return result;
 }
 
 @Override

  36. 36. data class Person(val name: String, val address: String)
  37. 37. Toast.makeText(applicationContext, "Hello, Kotlin!", Toast.LENGTH_SHORT).show()
  38. 38. // Define an extension function on Context fun Context.toast(message: String) {
 Toast.makeText(this.applicationContext, message, Toast.LENGTH_SHORT).show()
 } // available in class Context and its descendants toast("Hello, Kotlin!")
  39. 39. Happy Kotlin!

×