https://kotlinlang.org logo
#coroutines
Title
# coroutines
g

groostav

03/20/2017, 11:22 PM
Now this
break()
method does nothing but set a flag in the traversal logic, setting it not to continue. If I instead made this method be a
suspend val
and updated our source such that the
visit
methods were all
suspend funs
then I can get this:
Copy code
suspend val Visitor.break get() = Helpers.break(this)

override suspend fun visitEnter(node: NodeTypeTwo){
  if(node.modelB.isSpecialCase()){
    break //treated as a property-get
  }
  //domain logic b, never called when the above if-clause is taken as per the `break` suspension
}