Rules, and Lamdba with Lamdba

I’m trying to use the following lamdba

val duration = [ GenericItem s |

	if(now.getHour() > 6)

val switchControl = [ GenericItem item | //, Number duration, Number powerRequired, Number powerAvailable |

	duration.apply(item_bathroom_radiator) // This line will work

	duration.apply(item) // this line with not 

I found this article:

  • cannot see other globals, if you have a lambda that needs to call another lambda you must pass the second one as an argument

Are there any examples of this?

It’s pretty ugly.

Frankly, if you find yourself needing to do something like this it is a sure sign that you’ve outgrown Rules DSL. Any of the other rules languages would most likely serve you much better, even Blockly. Rules DSL simply does not support functions and other common programming paradigms well.

But if you want to persist with this approach you’ll need to do something like

val switchControl = [ GenericItem item, Function:Function1<GenericItem, BigDecimal> duration |

I’m going from years old memory here.

1 Like