Skip to content

Instantly share code, notes, and snippets.

@automationhacks
Created June 16, 2019 12:18
Show Gist options
  • Save automationhacks/602fa2e1dad405cacfb1ff518b11ed6c to your computer and use it in GitHub Desktop.
Save automationhacks/602fa2e1dad405cacfb1ff518b11ed6c to your computer and use it in GitHub Desktop.
Example KT class to show use of data classes
package _02_dataClasses
import org.testng.Assert
fun parseName(name : String): List<String> {
val space = name.indexOf(' ')
return listOf(
name.substring(0, space),
name.substring(space + 1)
)
}
fun main(args : Array<String>) {
val name = parseName("Jane Doe")
val first = name[0]
val last = name[1]
println("$first $last")
Assert.assertEquals(first, "Jane")
Assert.assertEquals(last, "Doe")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment