feld on Nostr: Just spotted an Elixir trick I haven't seen before def ...
Just spotted an Elixir trick I haven't seen before
def visible_for_user?(%{__struct__: module} = message, user)
when module in [Activity, Object] do
now that's a neat way to match on both struct types
Published at
2024-09-05 14:11:32Event JSON
{
"id": "54a78c932aea18593b33bc6659e742b36546dedf705a76c86869678f2919c353",
"pubkey": "83b033bb4b233dd0f295c71bda653b2eb624b7f5bed144db18110726c4ba4844",
"created_at": 1725545492,
"kind": 1,
"tags": [
[
"proxy",
"https://friedcheese.us/objects/47e73f66-6472-4b7d-b654-c7f2ba4b5b12",
"activitypub"
],
[
"L",
"pink.momostr"
],
[
"l",
"pink.momostr.activitypub:https://friedcheese.us/objects/47e73f66-6472-4b7d-b654-c7f2ba4b5b12",
"pink.momostr"
],
[
"-"
]
],
"content": "Just spotted an Elixir trick I haven't seen before\r\n\r\n def visible_for_user?(%{__struct__: module} = message, user)\r\n when module in [Activity, Object] do\r\n\r\n\r\nnow that's a neat way to match on both struct types",
"sig": "551394e80a886a3a2d879cc1f57d76da5b4a9d5b28395f218258a47eb79b83b571092a61d43abb9cdb1d585556b6802e54d9229a5d7248774b48c986886bb132"
}