From ac708dbe94ea2d373be34df04b7dd865cc327f8c Mon Sep 17 00:00:00 2001 From: Ali Dehghani Date: Sat, 30 May 2020 13:05:26 +0430 Subject: [PATCH] Added Elvis Operator --- .../kotlin/com/baeldung/ternary/TernaryOperatorTest.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt index 21dfdd2ae0..347290de72 100644 --- a/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt +++ b/core-kotlin-modules/core-kotlin-2/src/test/kotlin/com/baeldung/ternary/TernaryOperatorTest.kt @@ -21,4 +21,12 @@ class TernaryOperatorTest { } assertEquals("yes", result) } + + @Test + fun `using elvis`() { + val a: String? = null + val result = a ?: "Default" + + assertEquals("Default", result) + } } \ No newline at end of file