66件ヒット
[1-66件を表示]
(0.278秒)
検索結果
先頭5件
-
Object
# to _ str -> String (26113.0) -
オブジェクトの String への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
...面で代置可能であるような、
* 文字列そのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_str
'Edition'
end
end
it = Foo.new
p('Second' + it) #=> "SecondEdition"
//}
@see Object#to_s,Kernel.#String... -
ENV
. []=(key , value) (8036.0) -
key に対応する環境変数の値を value にします。 value が nil の時、key に対応する環境変数を取り除きます。
...を指定した場合は to_str メソッドによる暗黙の型変
換を試みます。
@param value 置き換えるべき値を指定します。文字列で指定します。文字列以
外のオブジェクトを指定した場合は to_str メソッドによる暗......黙
の型変換を試みます。
@return value を返します。
//emlist[][ruby]{
ENV['NEW_KEY'] = 'some_value'
ENV['NEW_KEY'] # => 'some_value'
ENV.store('NEW_KEY', nil) # => nil
ENV.has_key?('NEW_KEY') # => false
//}... -
ENV
. store(key , value) -> String (8036.0) -
key に対応する環境変数の値を value にします。 value が nil の時、key に対応する環境変数を取り除きます。
...を指定した場合は to_str メソッドによる暗黙の型変
換を試みます。
@param value 置き換えるべき値を指定します。文字列で指定します。文字列以
外のオブジェクトを指定した場合は to_str メソッドによる暗......黙
の型変換を試みます。
@return value を返します。
//emlist[][ruby]{
ENV['NEW_KEY'] = 'some_value'
ENV['NEW_KEY'] # => 'some_value'
ENV.store('NEW_KEY', nil) # => nil
ENV.has_key?('NEW_KEY') # => false
//}... -
String
# ==(other) -> bool (8024.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
stringlike = Object.new......def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
String
# ===(other) -> bool (8024.0) -
other が文字列の場合、String#eql? と同様に文字列の内容を比較します。
...to_str が定義されていれば
other == self の結果を返します。(ただし、 other.to_str は実行されません。)
そうでなければ false を返します。
@param other 任意のオブジェクト
@return true か false
//emlist[例][ruby]{
stringlike = Object.new......def stringlike.==(other)
"string" == other
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> false
def stringlike.to_str
raise
end
p "string".eql?(stringlike) #=> false
p "string" == stringlike #=> true
//}
@see String#eql?... -
Object
# to _ s -> String (8012.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...