BAEL-382 lambdas

This commit is contained in:
Tomasz Lelek 2017-01-17 16:09:05 +01:00
parent 2c0b55e4a3
commit 7fdf20df6b
2 changed files with 20 additions and 0 deletions

View File

@ -54,6 +54,7 @@ fun main(args: Array<String>) {
val sum = "four: ${2 + 2}"
val itemManager = ItemManager("cat_id", "db://connection")
ItemManager(categoryId = "catId", dbConnection = "db://Connection")
val result = "function result: ${itemManager.isFromSpecificCategory("1")}"
println(result)

View File

@ -0,0 +1,19 @@
package com.baeldung.kotlin
import org.junit.Test
import kotlin.test.assertEquals
class LambdaTest {
@Test
fun givenListOfNumber_whenDoingOperationsUsingLambda_shouldReturnProperResult() {
//given
val listOfNumbers = listOf(1, 2, 3)
//when
val sum = listOfNumbers.reduce { a, b -> a + b }
//then
assertEquals(6, sum)
}
}