Skip to content

Instantly share code, notes, and snippets.

@abdurahmanadilovic
Created January 28, 2018 12:22
Show Gist options
  • Save abdurahmanadilovic/e2e1ecd0ee2c69f8c96ea0ae2915c1c2 to your computer and use it in GitHub Desktop.
Save abdurahmanadilovic/e2e1ecd0ee2c69f8c96ea0ae2915c1c2 to your computer and use it in GitHub Desktop.
Kotlin map example
@Test
fun kotlinMap() {
val testContext = InstrumentationRegistry.getTargetContext()
val listOfLinks = listOf(
"www.codingstoic.com",
"www.codingblast.com",
"www.kotlinlang.org",
"www.android.com"
)
val listOfTextViews = listOfLinks.map {
val tmpTextView = TextView(testContext)
tmpTextView.text = it
tmpTextView
}
val rootView = LinearLayout(testContext)
listOfTextViews.forEach {
rootView.addView(it)
}
assertEquals(listOfLinks[0], listOfTextViews[0].text.toString())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment