Reputation: 345
I am trying to understand this code: https://github.com/CameronAavik/AdventOfCode/blob/master/Challenges/2018/Day03.fs
But I couldn't find any info about this "let something (...) { ... } = ..."syntax, for example:
let processBoundary (prevY, claimSet, total) {cursor=cursor; isAdding=isAdding; data=(top, height)} = ...
what is this? reminds me to a tuple and destructuring, but maybe it is not that.
thanks
Upvotes: 4
Views: 298
Reputation: 6629
It is actually destructuring as with a tuple, just that it's a record in this case.
A notable difference is that while with a tuple you have to match the exact number and position of the individual parts, when destructuring a record, you can leave out any of the fields you're not interested in at that point.
I wrote a (non-exhaustive) blog post on different ways of pattern matching/destructuring in F# once; maybe that's helpful in understanding here.
Upvotes: 5