{"action":"opened","issue":{"url":"https://api.github.com/repos/bramstein/funcy/issues/6","labels_url":"https://api.github.com/repos/bramstein/funcy/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/bramstein/funcy/issues/6/comments","events_url":"https://api.github.com/repos/bramstein/funcy/issues/6/events","html_url":"https://github.com/bramstein/funcy/issues/6","id":114101825,"number":6,"title":"Adding an optional guard condition","user":{"login":"AdamBrodzinski","id":1445367,"avatar_url":"https://avatars.githubusercontent.com/u/1445367?v=3","gravatar_id":"","url":"https://api.github.com/users/AdamBrodzinski","html_url":"https://github.com/AdamBrodzinski","followers_url":"https://api.github.com/users/AdamBrodzinski/followers","following_url":"https://api.github.com/users/AdamBrodzinski/following{/other_user}","gists_url":"https://api.github.com/users/AdamBrodzinski/gists{/gist_id}","starred_url":"https://api.github.com/users/AdamBrodzinski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AdamBrodzinski/subscriptions","organizations_url":"https://api.github.com/users/AdamBrodzinski/orgs","repos_url":"https://api.github.com/users/AdamBrodzinski/repos","events_url":"https://api.github.com/users/AdamBrodzinski/events{/privacy}","received_events_url":"https://api.github.com/users/AdamBrodzinski/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-10-29T17:19:14Z","updated_at":"2015-10-29T17:19:14Z","closed_at":null,"body":"I was wondering what you thought about potentially adding guard statements as an optional parameter? It basically would have to match the pattern plus the expression would have to be equal `true` for the match to execute.\r\n\r\nFor example Elixir has a pattern match and an optional guard:\r\n\r\n\r\n```elixir\r\ndef serve_drinks({age: age}) when age >= 21 do\r\n  # Code that serves drinks!\r\nend\r\n\r\nserve_drinks User.get(\"John Doe\")\r\n#=> Fails if the user is under 21\r\n```\r\n\r\nI've been tinkering with an experimental compile-to-js functional language that uses pattern matching and will be using this lib in my proof of concept compiler (also not prod ready). https://github.com/AdamBrodzinski/RedScript#pattern-matching-coming-soon\r\n\r\nI would love to contribute back if guard conditions are something you'd like to add.\r\n"}}