Contact Us 1-800-596-4880

functionReturnType

functionReturnType(t: Type): Type | Null

Returns the type of a function’s return type. This function fails if the input type is not a Function type.

Introduced in DataWeave version 2.3.0.

Parameters

Name Description

t

The function type.

Example

This example shows how functionReturnType behaves with different inputs.

Source

%dw 2.0
output application/json
import * from dw::core::Types
type AFunction = (String, Number) -> Number
type AFunction2 = () -> Number
---
{
    a: functionReturnType(AFunction),
    b: functionReturnType(AFunction2)
}

Output

{
  "a": "Number",
  "b": "Number"
}