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

type-parameterの演習問題のStackのメソッド定義について #37

Closed
xuwei-k opened this issue Feb 19, 2016 · 2 comments
Closed

Comments

@xuwei-k
Copy link
Contributor

xuwei-k commented Feb 19, 2016

https://github.com/dwango/scala_text/blob/f760890047eace599cd32546cc0c7d66075914b4/src/type-parameter.md#演習問題

immutableといっているし、(いずれにせよmutableだとしても) isEmpty などは副作用はないはずなので、
def isEmpty() ではなく def isEmpty にしておくべきではないか?

def pop() もある意味同様の問題があるが、空の場合は例外投げるので、副作用あると捉えることも可能(?)なので、微妙に別問題?

気がついてないだけで、同様の問題は他にもあるかもしれない

@kmizu
Copy link
Contributor

kmizu commented Feb 23, 2016

def pop()

も同様ですね。空の場合例外投げるというのは、副作用というよりpop()が部分関数(Scalaの意味ででなく、数学的な意味での)であることを表しているだけなので(部分関数であることを表現するために例外を使用しているというべきか?)。

@xuwei-k
Copy link
Contributor Author

xuwei-k commented Feb 24, 2016

https://github.com/dwango/scala_text/pull/41 で修正したのでひとまずclose
(他にもあれば、再openか、別途issueたてる)

@xuwei-k xuwei-k closed this as completed Feb 24, 2016
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

No branches or pull requests

2 participants