{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreiftp3nkyke2ua446xr6xftdy7pj42xo3apkzt6tt6m7mtup4d5spi",
"uri": "at://did:plc:kfvfl6lsmxg64yzszmfotdq2/app.bsky.feed.post/3mnbjes4tigb2"
},
"path": "/t/ruby-talk-444825-pattern-matching-as-string-passing-patters-to-functions/76779#post_3",
"publishedAt": "2026-06-01T05:54:32.000Z",
"site": "https://rubytalk.org",
"tags": [
"baweaver",
"The Case for Pattern Matching Key Irreverence in Ruby",
"github.com",
"GitHub - baweaver/dio: Dio - Dive Into Objects - Ruby Pattern Matching...",
"(click for more details)"
],
"textContent": "String keys do not work with pattern matching, or more specifically pattern\nexpressions in this case. The only way to get around that is to use\nsomething to symbolize the keys.\n\nThat said, I have argued before that we should treat pattern expression\nkeys as irrelevant, whether they are Strings or Symbols.\n\nbaweaver\n\n### The Case for Pattern Matching Key Irreverence in Ruby\n\nI had alluded to this post a bit earlier on Twitter, and in the Ruby bug tracker, but wanted to more...\n\nThe other option is to use something like Dio to make it irreverent for you:\n\ngithub.com\n\n### GitHub - baweaver/dio: Dio - Dive Into Objects - Ruby Pattern Matching...\n\nDio - Dive Into Objects - Ruby Pattern Matching interface for Objects which have none (yet)\n\nThe general direction of my argument in this regard is that pattern\nexpressions are exactly that: patterns. They are not Symbols, nor are they\nStrings, just as keyword arguments are keyword arguments and not Symbols\neither.\n\nRegarding your second point? Patterns are not first-class objects, unlike a\nregular expression, for example. However, you can cheat this one a bit more\nelegantly:\n\ncaptured_pattern = -> value { value in pattern: /match/ }\n\nYou use a function / proc / lambda / block to do it. That's also something\nI want, in addition to composable patterns (e.g., capturing a pattern and\nreusing it inside another one as a branch or a part of it.)\n\n··· (click for more details)",
"title": "[ruby-talk:444825] Pattern matching as String, passing patters to functions"
}