3件ヒット
[1-3件を表示]
(0.310秒)
検索結果
-
Hash
# to _ h -> self | Hash (73162.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
self を返します。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを... -
Hash
# to _ h {|key , value| block } -> Hash (73162.0) -
self を返します。Hash クラスのサブクラスから呼び出した場合は self を Hash オブジェクトに変換します。
self を返します。Hash クラスのサブクラスから呼び出した場合は
self を Hash オブジェクトに変換します。
//emlist[例][ruby]{
hash = {}
p hash.to_h # => {}
p hash.to_h == hash # => true
class MyHash < Hash;end
my_hash = MyHash.new
p my_hash.to_h # => {}
p my_hash.class # => MyHash
p my_hash.to_h.class # => Hash
//}
ブロックを... -
Object
# to _ hash -> Hash (36940.0) -
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。 デフォルトでは定義されていません。
オブジェクトの Hash への暗黙の変換が必要なときに内部で呼ばれます。
デフォルトでは定義されていません。
説明のためここに記載してありますが、
このメソッドは実際には Object クラスには定義されていません。
必要に応じてサブクラスで定義すべきものです。
このメソッドを定義する条件は、
* ハッシュが使われるすべての場面で代置可能であるような、
* ハッシュそのものとみなせるようなもの
という厳しいものになっています。
//emlist[][ruby]{
class Foo
def to_hash
{'as' => 24}
end
end
it = Foo...