-
Notifications
You must be signed in to change notification settings - Fork 601
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
Keyword lists / assert_raise ArgumentError #222
Comments
This is really great feedback, @robbyrussell! Thank you! It's always hard to keep your finger on the pulse of these koans as they grow and change over time. You have to work through them over and over to really feel out the flow (which tends to just not happen in reality). So this kind of feedback from the community is really important ❤️ |
Thanks @robbyrussell for the feedback! Would it make sense to flip the koans, move them to 08_maps and then compare maps to keyword lists? |
Possibly, I was just a bit thrown off by what the example was doing. (especially since it looked like I just needed to write the same thing as a few lines up but don't (yet) know why it'd trigger an ArgumentError |
(side-note: was really enjoying my way through this project. Was a fun Sunday afternoon project) |
Kind of similar here. The koan subject "But unlike maps, the keys in keyword lists must be atoms" explains the salient point, but I don't understand the syntax It's no big deal. This is my first exposure to Elixir so having to look things up to understand what's going on isn't an issue. [Some time later...] I found "The left to right arrow (->) is used to establish a relationship between left and right." but I'm having trouble figuring out what that actually means. Is this a common concept? My background is 10 years of Delphi dev. |
👋 @s-oram
Thanks for the link to the docs for one = fn -> 1 end
one.()
# => 1
add = fn x, y -> x + y end
add.(2,3)
# => 5 You'll sometimes see these written on multiple lines like: add = fn
x, y -> x + y
end 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" There's probably quite a bit more to say about all this, but hopefully it gives you a taste. Something to look out for is the shorthand syntax for anonymous functions: |
@iamvery That helps. Thanks for taking the time for the explanation. :) |
@iamvery do you want to turn that into Koan? 🤣 |
@felipesere I could try turning it into a koan if you would like? |
Yes, please! I see that 13_functions.ex should already cover most of it,
but please have a look and enhance and adjust as necessary ❤️💚💙💛
…On Wed, 4 Jul 2018 at 08:44 Shannon Oram ***@***.***> wrote:
@felipesere <https://github.com/felipesere> I could try turning it into a
koan if you would like?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#222 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABw7TFX39wf_6ewvqS0RLvP22dY0Lz6oks5uDHJigaJpZM4UGSKS>
.
|
@felipesere Great, I've got stuff on for the next couple of days. I'll aim to have something finished by the end of next week. |
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]
|
Koan added following comment on Github. elixirkoans/elixir-koans#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]
As a first timer to Elixir, I found myself scratching my head at the last koan for KeywordLists. It's the first function and dealing with raising an argument.
elixir-koans/lib/koans/07_keyword_lists.ex
Line 29 in 08c90ce
Nor have I been exposed to maps so this felt like I was just trying to get it to pass without really knowing why it is. (perhaps that's part of the point of Koans to get exposed to new things without understanding them yet?)
The text was updated successfully, but these errors were encountered: