2件ヒット
[1-2件を表示]
(0.019秒)
別のキーワード
キーワード
-
private
_ constant (1) -
public
_ constant (1)
検索結果
-
Module
# private _ constant(*name) -> self (69010.0) -
name で指定した定数の可視性を private に変更します。
...se NameError 存在しない定数を指定した場合に発生します。
@return self を返します。
@see Module#public_constant, Object#untrusted?
//emlist[例][ruby]{
module Foo
BAR = 'bar'
class Baz; end
QUX = 'qux'
class Quux; end
private_constant :QUX
private_constant :Q... -
Module
# public _ constant(*name) -> self (28.0) -
name で指定した定数の可視性を public に変更します。
...][ruby]{
module SampleModule
class SampleInnerClass
end
# => 非公開クラスであることを明示するために private にする
private_constant :SampleInnerClass
end
begin
SampleModule::SampleInnerClass
rescue => e
e # => #<NameError: private constant SampleModule::SampleInne......rClass referenced>
end
module SampleModule
# => 非公開クラスであることは承知で利用するために public にする
public_constant :SampleInnerClass
end
SampleModule::SampleInnerClass # => SampleModule::SampleInnerClass
//}
@see Module#private_constant, Object#untrusted?...