BAEL-382 lambdas
This commit is contained in:
parent
2c0b55e4a3
commit
7fdf20df6b
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue