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

tryの是非 #73

Open
kzytateishi opened this issue Jul 27, 2013 · 1 comment
Open

tryの是非 #73

kzytateishi opened this issue Jul 27, 2013 · 1 comment

Comments

@kzytateishi
Copy link
Contributor

class Hoge < ActiveRecord::Base
  has_many :aaa
end
@hoge.try(:aaa).try(:bbb)

・仕様変更でaaaがcccに変わったときに

class Hoge < ActiveRecord::Base
  has_many :ccc
end

・tryで握り潰されてしまっているのでエラーが出ない。

@hoge.try(:aaa).try(:bbb)

tryは使わない方がいい...?

@sakamoto-rh
Copy link

[まとめ]
例外をいきなりつぶすのは良くない。
その為、いきなりtryを使わずに例外を出した上で、開発がtryで握りつぶすか否かを話し合うことが大事。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants