how do i return a method in a `with` ?
# getting-started
h
how do i return a method in a
with
?
p
Copy code
val foo = "Hello"
with(foo) { 
    println(foo)
    fun (): String { return foo}
}
h
not what i meant
Copy code
fun something(): Int{
  foo.apply{
   //do stuff
  return 5
  }
}
can’t do that
p
delete
return
lambdas implicitly return whatever is on the last line
h
ah, ok
here is a tiny block of code
c
Copy code
class Foo(val bar: String)

fun somthing(): String {
    val foo = Foo("something")
    foo.apply { 
        return@somthing bar
    }
    return "else"
}
h
see line 31?
i want to return there
c
can use
return@
as well
h
but what do i return to?
i can’t do return@generateTransaction
p
well what do you want to return to? we don't know, the compiler doesn't either
h
unless doing return@paypalErrorAware will work?
c
I think it should…
editor should help you out tho
p
nasty code anyways.. i would refactor this
h
any suggestions? they are welcome
Still learning kotlin, and used to java .-.