commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henrib <>
Subject Re: [Jexl] Return statement
Date Thu, 16 Feb 2012 13:16:40 GMT
Hi Naren,
I've tried to reproduce your problem and failed so I must be missing
Here is the code I tried on 2.1 trunk (added to
    public void test130() throws Exception {
        JexlEngine jexl = new JexlEngine();
        String[] items = { "foo" , "bar", "quux" };
        Script s = jexl.createScript("for(var x : items) { if(x.equals(y)) {
return true; } }", "items", "y"); 
        Object r = s.execute(null, items, "bar");
        assertEquals(true, r);
        r = s.execute(null, items, "froboz");
        JexlContext ctxt = new MapContext();
        ctxt.set("items", items);
        ctxt.set("y", "bar");
        s = jexl.createScript("for(x : items) { if(x.equals(y)) { return
true; } }");
        r = s.execute(ctxt);
        assertEquals(true, r);
        ctxt.set("y", "froboz");
        r = s.execute(ctxt);

I've also tried with out the 'var x' and a MapContext  and with an added
'return false' at the end but couldn't make it fail.
Can you post the actual code that fails on your end?

View this message in context:
Sent from the Commons - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message