Created
January 28, 2018 12:32
-
-
Save abdurahmanadilovic/4c0a2fea3ed076a522f7cf8ae67dbfde to your computer and use it in GitHub Desktop.
Kotlin map forEach example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun kotlinMap() { | |
val testContext = InstrumentationRegistry.getTargetContext() | |
val rootView = LinearLayout(testContext) | |
listOf( | |
"www.codingstoic.com", | |
"www.codingblast.com", | |
"www.kotlinlang.org", | |
"www.android.com" | |
).map { | |
val tmpTextView = TextView(testContext) | |
tmpTextView.text = it | |
tmpTextView | |
}.forEach { | |
rootView.addView(it) | |
} | |
assertEquals("www.codingstoic.com", (rootView.getChildAt(0) as TextView).text.toString()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment