132件ヒット
[101-132件を表示]
(0.052秒)
別のキーワード
ライブラリ
- ビルトイン (132)
キーワード
-
_ dump (12) - clone (12)
- dup (12)
-
initialize
_ copy (12) - inspect (12)
-
instance
_ variable _ defined? (12) -
instance
_ variable _ get (12) -
marshal
_ dump (12) -
singleton
_ method (12) -
to
_ s (12)
検索結果
-
Object
# inspect -> String (3038.0) -
オブジェクトを人間が読める形式に変換した文字列を返します。
...返します。
組み込み関数 Kernel.#p は、このメソッドの結果を使用して
オブジェクトを表示します。
//emlist[][ruby]{
[ 1, 2, 3..4, 'five' ].inspect # => "[1, 2, 3..4, \"five\"]"
Time.new.inspect # => "2008-03-08 19:43:39 +0900"
//}
inspect メ......変数の名前、値の組を元にした文字列を返します。
//emlist[][ruby]{
class Foo
end
Foo.new.inspect # => "#<Foo:0x0300c868>"
class Bar
def initialize
@bar = 1
end
end
Bar.new.inspect # => "#<Bar:0x0300c868 @bar=1>"
//}
@see Kernel.#p... -
Object
# instance _ variable _ defined?(var) -> bool (3038.0) -
インスタンス変数 var が定義されていたら真を返します。
...す。
@param var インスタンス変数名を文字列か Symbol で指定します。
//emlist[][ruby]{
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
p fred.instance_variable_defined?(:@a) #=> true
p fred.instance_variable_defined?("@b") #=>......true
p fred.instance_variable_defined?("@c") #=> false
//}
@see Object#instance_variable_get,Object#instance_variable_set,Object#instance_variables... -
Object
# to _ s -> String (3026.0) -
オブジェクトの文字列表現を返します。
...使って文字列に変換し
ます。
//emlist[][ruby]{
class Foo
def initialize num
@num = num
end
end
it = Foo.new(40)
puts it #=> #<Foo:0x2b69110>
class Foo
def to_s
"Class:Foo Number:#{@num}"
end
end
puts it #=> Class:Foo Number:40
//}
@see Object#to_str,Kernel.#String...