๐ WAYPOINT LESSON
Checkpoint โ Methods Under Contract
โญโญ intermediateโณ 20 min read๐ Lesson 93 of 265
Combine out/ref discipline, overload-shape design, and bounded recursion in one graded unit.
The gate
Three functions, one graded unit:
- A
TryXparser family:TrySplitRatio("3:5", out int a, out int b)โ true only for two positive integers separated by exactly one colon. - A swap-with-history:
SwapWithCount(ref int a, ref int b)swaps the two and returns how many times THIS method has swapped (static state). FlattenDepth(object[][] groups, int depth)โ sums nested arrays to a fixed depth (depth 1 sums inner arrays; depth 0 is just the outer sums; negative depth returns 0) using recursion, honestly bounded.
Passing means you can state each contract's reason, not just its shape.