Skip to content

Conversation

@44103
Copy link
Owner

@44103 44103 commented May 24, 2020

第7章(と第6章)を追加
確認お願いします。

Comment on lines +5 to +9
defp _max([head | tail], value) when head > value do
_max(tail, head)
end
defp _max([head | tail], value) when head <= value do
_max(tail, value)
Copy link

Choose a reason for hiding this comment

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

第12章先取りになっちゃうけど,ガードでやるかcaseでやるかifでやるかは諸説あるので,別の書き方もあるって感じで書いときます
ただ,ページエラーの404とか分けるときはcaseが良さそうみたいなのを聞きました.

defp _max([head | tail], value) do
  case head > valuse do
    true -> _max(tail, head)
    false -> _max(tail, value)
  end
end

defp _max([head | tail], value) do
  if head > value do
    _max(tail, head)
  else
    _max(tail, value)
  end
end

Copy link
Owner Author

Choose a reason for hiding this comment

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

なるほど。
if は第10章で出てきてることを確認しました。
case, if 共に出てきたときにぜひ、それぞれの利点をお聞きしたいです。

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