<p>Is there a way to get MVEL 2.0 ( <a href="http://mvel.codehaus.org/" rel="nofollow noreferrer">http://mvel.codehaus.org/</a> ) to work with functions with optional parameters?</p>

<p>I would like to be able to eval this:</p>

<p>trunc('blahblah',2)</p>

<p>but also</p>

<p>trunc('blahblah',2,'[...]');</p>

<p>Now i have tried: </p>

<p>def trunc(param1,param2,param3) { ... impl ... }</p>

<p>That gives an exception if i try to call it with only 3 parameters.
I also tried:</p>

<p>def trunc(param1,param2,param3) { ... impl ... }
def trunc(param1,param2) { ... impl ... }</p>

<p>But the second one seems to completely overwrite the first definition.</p>

<p>Thanks</p>

In java you can declare multiple methods with the same name, but a different arguments.
That way you can support (in a limited way) optional parameters.
Eg.:
```
```
private void method(Object obj1) {
    Object obj2 = new Object("Default");
    method(obj1, obj2);
}

private void method(Object obj1, Object obj2) {
    doStuff(...);
}
```
```
Calling method() is possible with one or two arguments :)