I recently became aware of a generics-like notation to denote polymorphic types in DW 2.0.
The example below
%dw 2.0
output application/dw
fun id1(a) = a
fun id2(a: Any) = a
fun id3<T>(a: T) = a
var id4 = <T>(a: T) -> a
---
{
"d1": id1,
"d2": id2,
"d3": id3,
"d4": id4,
r1: id1(10),
r2: id2(10),
r3: id3(10),
r4: id4(10)
}
Illustrates that the signatures and the semantics of these functions are the same.
Which begs the question what is the difference between these definitions if any? Which one would you recommend?
Finally, confirm my assumption that DW 2.0 borrowed this generics-like syntax found in OO languages to support explicit polymorphic types.
NOTE: I did use application/dw
in order to see the sigs of the functions while running the Preview from Anypoint Studio
TIA!