DEV Community

Discussion on: Ruby 3 Pattern Matching Applied: Poker

Collapse
 
mlibby profile image
Michael C. Libby
RANKS  = [*2..10, *%w(J Q K A)].map(&:to_s).freeze
Enter fullscreen mode Exit fullscreen mode

looks clever, but is also sort of hard to read/understand. Even if you're fluent in the syntax and functionality involved it has a higher cognitive load than

RANKS = %w(2 3 4 5 6 7 8 9 10 J Q K A).freeze
Enter fullscreen mode Exit fullscreen mode

which I think does the same thing, but also has the benefit of less typing.

Whenever I see something complicated looking that just does something simple, I spend a lot of time wondering what it is I missed. Am I missing something here?

Collapse
 
baweaver profile image
Brandon Weaver

Not really, most of the point of these posts is not always to be 100% clear as much as be a ride through a lot of new features to explore and think about. If I were writing this as production code it'd look a fair bit different, but that might be a followup article as well.

Most of the reason for that is that it's quicker to type in a REPL when I'm testing things.

Collapse
 
mlibby profile image
Michael C. Libby

That makes sense, thanks.