|
Re: Variable defined (or not): msg#00120lang.groovy.user
Thanks! Groovy is embedded and called from servlet (data contains request parameters as HashMap): ========================================= Servlet clip: groovy.lang.Binding binding = new groovy.lang.Binding(data); GroovyShell shell = new GroovyShell(binding); shell.evaluate( new File(fileName) ); ========================================= Testfile: if(a!=null) b=[5, 9, 2, 2, 4, 5, 6].join("abc"); else b=[5, 9, 2, 2, 4, 5, 6].join(" - "); ========================================= Results exception: groovy.lang.MissingPropertyException: No such property: a for class: groovy at groovy.lang.MetaClass.getProperty(MetaClass.java:697) - - --- Jeremy Rayner <groovy-WROaGtoGdBGWkzVdRvz7FA@xxxxxxxxxxxxxxxx> wrote: > On Fri, Oct 15, 2004 at 04:28:58AM -0700, juhani wrote: > > Hi! How do you test if variable is defined or not? > Hi, not sure of the context in which you're thinking, > but inside a groovy script all variables are an object > so a simple test for null should do the trick > if (foo != null) { > println foo > } else { > println "foo is undefined" > } > Hope that helps __________________________________ Do you Yahoo!? Yahoo! Mail Address AutoComplete - You start. We finish. http://promotions.yahoo.com/new_mail
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: Did anyone post a response to "the optional features considered sucky" article, John Rose |
|---|---|
| Next by Date: | Re: Variable defined (or not), juhani |
| Previous by Thread: | Re: Variable defined, Jeremy Rayner |
| Next by Thread: | Re: Variable defined (or not), juhani |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |