Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次のような使用法に出くわしました。
InvalidRequest = Class.new(StandardError)
私は混乱しています:
Class.new
引数を持つクラスをスーパークラスとして設定します。
Class.new に引数を渡す意味は何ですか?
引数は、返される新しい無名クラスのスーパークラスとして使用されます。
InvalidRequest、StandError、Class の関係はどうなっていますか?
InvalidRequest Classから継承 するですStandardError。
InvalidRequest
Class
StandardError
機能的には次のものと同等です。
class InvalidRequest < StandardError end
より機能的なプログラミングスタイルで。