rights reserved. fun hasItem(list: List<Int>, predicate: (item: Int) -> Boolean): Boolean { for (i in list) { if (predicate(i)) return true } return false } 関数リテラル
rights reserved. fun hasItem(list: List<Int>, predicate: (item: Int) -> Boolean): Boolean { for (i in list) { if (predicate(i)) return true } return false }
rights reserved. fun hasItem(list: List<Int>, predicate: (item: Int) -> Boolean): Boolean { for (i in list) { if (predicate(i)) return true } return false }
rights reserved. fun hasItem(list: List<Int>, predicate: (item: Int) -> Boolean): Boolean { for (i in list) { if (predicate(i)) return true } return false }
rights reserved. fun hasItem(list: List<Int>, predicate: (item: Int) -> Boolean): Boolean { for (i in list) { if (predicate(i)) return true } return false }
rights reserved. fun sum(nums: List<Int>): Int { tailrec fun go(nums: List<Int>, acc: Int): Int = if (nums.isEmpty()) acc else go(nums.drop(1), acc + nums.first()) return go(nums, 0) } ⾼階関数
rights reserved. fun sum(nums: List<Int>): Int { tailrec fun go(nums: List<Int>, acc: Int): Int = if (nums.isEmpty()) acc else go(nums.drop(1), acc + nums.first()) return go(nums, 0) }
rights reserved. fun sum(nums: List<Int>): Int { tailrec fun go(nums: List<Int>, acc: Int): Int = if (nums.isEmpty()) acc else go(nums.drop(1), acc + nums.first()) return go(nums, 0) } ☞ 末尾再帰最適化
rights reserved. fun sum(nums: List<Int>): Int { tailrec fun go(nums: List<Int>, acc: Int): Int = if (nums.isEmpty()) acc else go(nums.drop(1), acc + nums.first()) return go(nums, 0) }
rights reserved. data class Task @JvmOverloads constructor(val id: Long, val content: String, val done: Boolean = false) // from Java new Task(1, "foo"); new Task(2, "bar", true);
rights reserved. data class Task @JvmOverloads constructor(val id: Long, val content: String, val done: Boolean = false) // from Java new Task(1, "foo"); new Task(2, "bar", true);
rights reserved. data class Task @JvmOverloads constructor(val id: Long, val content: String, val done: Boolean = false) // from Java new Task(1, "foo"); new Task(2, "bar", true);
rights reserved. data class Task @JvmOverloads constructor(val id: Long, val content: String, val done: Boolean = false) // from Java new Task(1, "foo"); new Task(2, "bar", true);