Doesn’t work like that in openHAB rules. You can define functions, but with a different form and generally referred to as ‘lambdas’.