Yahoo! JAPANとKotlin

303 views

Published on

JetBrains東京ナイトの発表資料です
https://www.jetbrains.com/languages/jp/jetbrains-night-2016/

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
303
On SlideShare
0
From Embeds
0
Number of Embeds
57
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Yahoo! JAPANとKotlin

  1. 1. 

  2. 2. // 
 val square: (Int) -> Int = { it * it }
 square(2) //-> 4 
 // 
 fun sort(algorithm:(Int, Int) -> Boolean) {
 //...
 }
 sort { first, second -> first < second }
  3. 3.
  4. 4. //null 
 var notNullable:String = "world"
 notNullable = null // //null var nullable:String? = "hello"
 nullable = null // if ? 
 println(nullable?.capitalize())
  5. 5. fun String.twice() = "${this}, ${this}"
 
 println("hello".twice())
 // -> hello, hello
  6. 6.
  7. 7. private fun startLongAsyncOperation(v: Int) =
 CompletableFuture.supplyAsync {
 Thread.sleep(1000)
 "Result: $v"
 }
 
 fun main(args: Array<String>) {
 val future = async<String> {
 (1..5).map {
 await(startLongAsyncOperation(it))
 }.joinToString("n")
 }
 
 println(future.get())
 } // 5 Result: 1 Result: 2 Result: 3 Result: 4 Result: 5

×