Closure evaluation

Discussions about the LSPS expression language.
Forum rules
Make sure every topic contains information about your LSPS version and if relevant also your server OS, client OS, database name and version, and application server name and version.
djeison.selzlein
 
Posts: 34
Joined: Fri Feb 27, 2015 4:38 pm

Closure evaluation

Thu Jun 11, 2015 8:52 pm

Hi, how can I evaluate a closure like this { : String } to a String?
I am getting the following exception on: "Type mismatch. Cannot convert from { : String} to String". I believe it is simple to solve but I am not sure how to do that and I could not find examples on how to do it.

Thanks in advance.

Maros Bajtos
 
Posts: 145
Joined: Mon Feb 27, 2012 2:52 pm

Re: Closure evaluation

Thu Jun 11, 2015 9:08 pm

{:String} is a closure. To get a string you just need to call it, see the following example:

Code: Select all
def {:String} stringClosure := { -> "test"};
def String string := stringClosure();
debugLog({ -> string}, 200);

Maros Bajtos
 
Posts: 145
Joined: Mon Feb 27, 2012 2:52 pm

Re: Closure evaluation

Thu Jun 11, 2015 9:10 pm

This is also mentioned in ExpressionLanguageRefcard - Closure invocation: closure(argument_1, argument_2,...)

djeison.selzlein
 
Posts: 34
Joined: Fri Feb 27, 2015 4:38 pm

Re: Closure evaluation

Thu Jun 11, 2015 9:57 pm

Ok, perfect. Thank you a lot Maros.

Return to Expression language

Who is online

Users browsing this forum: No registered users and 1 guest