Yes, this line declares two variables and calls the function e1 , binding the variables to the result of the function call.
This method of binding variables is called pattern matching. It is based on information about the return type of the e1 function - the compiler knows that it returns a tuple, and then it can be decomposed into parts, and these parts are bound to two new variables testAST and tokens2 . This is one of the most powerful FP features that allows you to write much more readable, flexible, and shorter code.
It can also be done (agreed) on everything if the structure of this object (template) is known to the compiler (for example, case classes in Scala, tuples and lists in Haskell, entries in Erlang, etc.). Also, pattern matching can be used to ignore some parts of the structure that are not relevant to the conditions (for example, in Haskell, if you want to select the second element in three tuples, just do selectSecond (_, a, _) = a , where _ is special character to ignore values).
source share