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": "c4bc879aa340956861a08c509057bf8e85d3e24cd9f09e9f280838649efe2e35",
"pubkey": "c517f9a012aa4a98fec69f150764a70e77e3c21a326277fdb788fe3dd0b410f9",
"created_at": 1725545492,
"kind": 1,
"tags": [
[
"zap",
"c517f9a012aa4a98fec69f150764a70e77e3c21a326277fdb788fe3dd0b410f9",
"wss://relay.mostr.pub",
"0.915"
],
[
"zap",
"6be38f8c63df7dbf84db7ec4a6e6fbbd8d19dca3b980efad18585c46f04b26f9",
"wss://relay.mostr.pub",
"0.085"
],
[
"proxy",
"https://friedcheese.us/objects/47e73f66-6472-4b7d-b654-c7f2ba4b5b12",
"activitypub"
]
],
"content": "Just spotted an Elixir trick I haven't seen before\n\n def visible_for_user?(%{__struct__: module} = message, user)\n when module in [Activity, Object] do\n\n\nnow that's a neat way to match on both struct types",
"sig": "5a6ccdb961cb667c374c34a0c7ff1b5ee24feefeb2c2aece96161a1152e223716a3603244755f289f2e398f3dd304c0c73aaf88e808474c90e7f275aa486d638"
}