以下の内容はhttps://secret-garden.hatenablog.com/entry/2017/08/09/214431より取得しました。


Ruby で内部クラスを private にする

Ruby で内部クラスを private にする場合どうするのがよいかと思っていたんですが private_constant を使うのがいいみたい。

class X
    class A
        
    end

    class B
        
    end
    private_constant :B

    def self.B_new
        B.new
    end
end

# OK
X::A.new

# Error: private constant X::B referenced (NameError)
# X::B

# OK
X.B_new



以上の内容はhttps://secret-garden.hatenablog.com/entry/2017/08/09/214431より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14