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 elixir version (without tests) #47
Conversation
Should the _build folder be part of the commit? |
The readme is very comprehensive. I am not sure we need that information after the pr has been merged. Most translation only have a readme for how to build and run tests. So please put the porting related information into the PR descriptions and keep the readme short, only listening what is needed, if at all, like |
Also the gitignore seems to be missing from this PR. |
Oops, no, definitely not! Looks like I lost the |
Accidentally lost it when copying files from other branch
Above comments addressed. |
discount = nil | ||
x = 1 | ||
|
||
{discount, x} = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately I do not know much about Elexir.... Is the cond
expression strictly necessary here? In the other languages this is the first step people have to consolidate the code which is more imperative and having different updates in the branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that in Elixir variables are immutable (but can be rebound, and shadowed in nested scopes). So if we reproduced the shape of the java code along these lines (there’s no elseif
, but cond
is similar):
x = 1
cond do
offer.offer_type == :three_for_two) ->
x = 3
offer.offer_type == :two_for_amount ->
x = 2
# etc
end
… then x
would always end up with the value of 1
, because the x = 3
and x = 2
are creating separate variables in their own block scopes. The only way to set a variable based on a conditional is to assign the result of the conditional to the variable.
Thank you looks much better now. I had a closer look at the code and have a question regarding one construct. Please see comment in code |
Thank you. Looks good then. This could be merged @emilybache |
See PR #46 for version with tests.