Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add koan "You can use pattern matching to define [...]" #224

Merged
merged 3 commits into from
Jul 12, 2018

Conversation

s-oram
Copy link
Contributor

@s-oram s-oram commented Jul 11, 2018

Add new koan after discussion in Github issue:
#222 (comment)

[quote]
And, in fact, you can define multiple cases for a function using this sytnax:

lolwat = fn
  "lol" -> "wat"
  _ -> "haha"
end
lolwat.("lol")
# => "wat"
lolwat.("anything")
# => "haha"
lolwat.("rly")
# => "haha"

[/quote]

Koan added following comment on Github.
elixirkoans#222 (comment)

[quote]
And, in fact, you can define multiple cases for a function using this sytnax:

```
lolwat = fn
  "lol" -> "wat"
  _ -> "haha"
end
lolwat.("lol")
# => "wat"
lolwat.("anything")
# => "haha"
lolwat.("rly")
# => "haha"
```

[/quote]
Copy link
Collaborator

@felipesere felipesere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe rename “format_reault” to something like inspirational_quote? It would at least sound right for the :ok arm of the function 😅

@s-oram
Copy link
Contributor Author

s-oram commented Jul 11, 2018

@felipesere You're right, that does read better. I've renamed the function. Thanks for reviewing the pull request. Is there anything else? :)

@felipesere
Copy link
Collaborator

Yeah, one key thing is keeping CI happy.
If you look under /test you can see tests for all Koans. Essentially we ensure that the right answer (or answers) complete the koan. I’m on my phone this instant but I can give you more hints to later if needed 🤓

Copy link
Collaborator

@iamvery iamvery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! ❤️💙💚💛💜

Just needs answers added to the test suite to keep CI green 🍏

@s-oram
Copy link
Contributor Author

s-oram commented Jul 11, 2018

Thanks guys, I'll take a look at those tests for the CI. :)

[edit] The expected koan result has been added to functions_koans_test.exs.

@felipesere felipesere merged commit 554ad1c into elixirkoans:master Jul 12, 2018
@felipesere
Copy link
Collaborator

Thank you!!!

@s-oram
Copy link
Contributor Author

s-oram commented Jul 13, 2018

Thanks Felipe! :)

w0rd-driven pushed a commit to w0rd-driven/elixir-koans that referenced this pull request Jan 15, 2020
Add koan "You can use pattern matching to define [...]"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants