Hi there,

I've just bumped into this behaviour, as shown e.g., by the code quoted below. 
A safe method call first evaluates method's arguments, and only then trashes 
the call.

Is this the intended behaviour? It would seem to me much better if the 
arguments were not evaluated in this case (precisely same way as if we used the 
java-like  “if (obj) obj.whatever...” approach instead of the safe call) — but 
perhaps I am overlooking something of importance.

Thanks,
OC

===
1040 ocs /tmp> <q.groovy 
class qq {
  def foo(String s) {
    println "foo called!"
    s
  }
  def bar(String s) {
    println "bar: $s"
  }
}

null?.bar(new qq().foo('Oops!'))
1041 ocs /tmp> /usr/local/groovy-4.0.25/bin/groovy q
foo called!
1042 ocs /tmp> 
===

Reply via email to