t3wad
10/31/2015, 2:55 PM//Before
class MyClass() : SomeLibrary {
override fun someLibraryInitMethod() {
var theSomething = newSomething()
}
private fun useTheSomethingLater() {
theSomething.doSomething() //in error since theSomething isn't in scope
}
...
becomes (after putting cursor on "theSomething" and selecting "Extract ...")
//After
class MyClass() {
private lateinit var something : Something
override fun someLibraryInitMethod() {
theSomething = newSomething()
}
private fun useTheSomethingLater() {
theSomething.doSomething() //now not in error
}
}
Or perhaps there is a better way to code that in general with Kotlin, avoiding the concern?