Skip to main content
๐Ÿ“œ 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:

  1. A TryX parser family: TrySplitRatio("3:5", out int a, out int b) โ€” true only for two positive integers separated by exactly one colon.
  2. 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).
  3. 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.