Groovy web console

subscribe to the feed Subscribe
to this
site

Optional return keyword

Published 3 weeks ago by ZCoffin with tags semantics optionality return
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
class A {
  static String test() {
    String foo
    foo = "a"
    if (false) {
      foo = "b"
    }
  }
}

class B {
  static String test() {
    String foo
    foo = "a"
    if (true) {
      foo = "b"
    }
  }
}

println(A.test()) // null
println(B.test()) // b