groovy - how do I make sure a function does not return Null -


i'm trying parse xml request in soapui. , when parse node without in it, logically string null if defining func() returns null:

def groovyutils = new com.eviware.soapui.support.groovyutils( context ) def request = groovyutils.getxmlholder( mockrequest.requestcontent )     def argumentstring = request.getnodevalue("/soap:envelope/soap:body[1]/emm:runapplication[1]/emm:argument[1]") 

now tried doing this:

try{argumentstring.length()}catch(e){argumentsstring = " "} 

but kills process after correction, , doesn't quite give want. can't use simple if(func()!=null) i'm used in java? how can this? help!

you can test null values ...:
argumentstring = (argumentstring != null) ? argumentstring : " "

btw, argumentstring?.length(), length() evaluated if argumentstring isn't null.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -