You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This builds on proposal #124 like proposals #139 and #140 but for the array literal syntax:
Select Case arr
Case Match {} ' Empty.
Case Match {single} ' One element
Case Match {first, second} ' This could work.
Case Else ' Must have more than 2 elements.
End Select
Would it work for arbitrary collections? IEnumerables?
Unanswered.
Would it be very valuable to have a sort of "the rest" syntax
I could imagine a syntax like:
Case Match {first, ...}
That captures the first element but allows for sizes greater than one but that seems of extremely marginal benefit for syntax compared with just grabbing the array and manually extracting values.
The text was updated successfully, but these errors were encountered:
Unless this also supported IEnumerable efficiently (as in, not enumerating multiple times), I don't see it being of much benefit. Most public APIs use IEnumerable (or something similar that's not an array). In fact, Microsoft's own guidelines state not to use arrays publicly.
✓ DO prefer using collections over arrays in public APIs.
Maybe an alternative (or even in addition to the matching) would be something like TypeScript/ES6 array destructuring.
Rest syntax is useful for recursive definitions, especially if tail recursive optimised.
Or using a Functional Language List.
Function[Me](numsAsInt(),OptionalsumAsInt=0)AsInt' NOTE: I'm using Match instead of Case, this indicates ALL clause are to considered match syntax.SelectMatchnumsCase{num}:returnsum+numCase{num,rest:...}:return[Me](rest,sum+num)Case{}:returnsumEndSelectEndFunction
This builds on proposal #124 like proposals #139 and #140 but for the array literal syntax:
Would it work for arbitrary collections? IEnumerables?
Unanswered.
Would it be very valuable to have a sort of "the rest" syntax
I could imagine a syntax like:
That captures the first element but allows for sizes greater than one but that seems of extremely marginal benefit for syntax compared with just grabbing the array and manually extracting values.
The text was updated successfully, but these errors were encountered: