-
Notifications
You must be signed in to change notification settings - Fork 64
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
Pattern matching on Cloudex.upload/2 departs from Elixir conventions? #20
Comments
The reason is that Cloudex.upload/2 can handle a single file, multiple files, or a directory. Thus the result you get back is a list with a result for each file it uploaded, in case that you uploaded only one file, you will get a list with one element. if you uploaded a directory for example you would get a result per uploaded file. for example :
Hope this makes sense for you :) |
Thanks, that makes sense. I don't mean to nitpick, but I was curious. Another thing that peaked my interest was passing the opts to upload as a map, versus a keyword list, which you tend to see in most examples. |
No problem, always ask :) Regarding a map vs keyword list, this is mostly a personal preference. Practically a keyword list is ordered and thus makes it a lot harder to use for function head pattern matching when there are a lot of options, since you need to make sure you use the same order as the function head expects. With a map its a lot easier to match on specific elements, no matter what the order. |
Great, thank you the explanations and, of course, for Cloudex. 👍 |
Correct me if I'm wrong, but it seems that pattern matching for
Cloudex.upload/2
departs from Elixir conventions.Normally, in Elixir we do something like this:
Cloudex returns a list, however. How come?
The text was updated successfully, but these errors were encountered: