Description
Transforms an input value using a Ruby compliant lambda expression.
Syntax
xplenty_rb.transform(val, lambda_expression)
Arguments
val - any value (can be a simple data type or a complex data type
lambda_expression - string containing a Ruby compliant expression to manipulate the input value.
Examples
xplenty_rb.transform('f818', '|x| x.to_i(16)')
returns 63512
xplenty_rb.transform(JsonStringToBag('[1,2,3]'), '|x| x.to_a[0][0]')
returns 1
* to_a is used to transform a bag into an array. [0][0] is used becasue bags contains tuples (arrays) of fields. xplenty_rb.transform(JsonStringToBag('[1,2,3]'), '|x| x.join("")')
returns 123
Return value datatype
Binary (byte array). You may further cast the returned value in order to pass it to other functions.
Impact of null value
If input is null, returns null.
If the lambda expression is null or erroneous, the function fails.