def x=2 def y=3 if(x == y){ log.info "equal" }else{ log.info "not equal" // print out not equal } TestService s1 = new TestService() TestService s2 = new TestService() log.info s1.is(s2) // false s1=s2 log.info s1.is(s2) // true class TestService{ }
Run result:
Tue Oct 06 21:04:38 CST 2015:INFO:not equal Tue Oct 06 21:04:38 CST 2015:INFO:false Tue Oct 06 21:04:38 CST 2015:INFO:true