Playing a Hand with Ruby Pattern Matching
summary
Code shows Ruby 2.7 pattern matching scoring poker hands by building Card and Hand classes, implementing deconstruct hooks, Comparable-based sorting, and one-liner match syntax. Examples use named captures and the pin operator, array destructuring, fine patterns and pinned ranks to detect royal flush down to high card. The talk ties predicates into a score map, runs the examples against sample hands, and the tests all pass, proving the approach works for this concrete problem.
AI-written summary · about
chapters (9)
- 0:00Introduction
- 2:13Ruby pattern matching
- 4:42Card and hand structures
- 8:12Easy card creation
- 12:47Sorting cards and hands
- 15:13Poker hand types
- 22:31Scoring poker hands
- 29:14Beyond poker
- 30:58Q&A








