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.

Yahoo! JAPANとKotlin

1,327 views

Published on

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

Published in: Technology
  • Be the first to comment

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

×