るりまサーチ

最速Rubyリファレンスマニュアル検索!
17件ヒット [1-17件を表示] (0.020秒)

別のキーワード

  1. _builtin hash
  2. hash []
  3. matrix hash
  4. dbm to_hash
  5. _builtin to_hash

ライブラリ

クラス

キーワード

検索結果

Hash#except(*keys) -> Hash (39243.0)

引数で指定された以外のキーとその値だけを含む Hash を返します。

...引数で指定された以外のキーとその値だけを含む Hash を返します。

引数に指定されていて Hash に存在しないキーは無視されます。

//emlist[][ruby]{
h = { a: 100, b: 200, c: 300 }
h.except(:a) # => {:b=>200, :c=>300}
//}

@see Hash#slice, ENV.except...

Hash#slice(*keys) -> Hash (21130.0)

引数で指定されたキーとその値だけを含む Hash を返します。

...引数で指定されたキーとその値だけを含む Hash を返します。

//emlist[例][ruby]{
h = { a: 100, b: 200, c: 300 }
h.slice(:a) # => {:a=>100}
h.slice(:c, :b) # => {:c=>300, :b=>200}
h.slice(:b, :c, :d) # => {:b=>200, :c=>300}
//}

@see Hash#except, ENV.slice...

Exception#to_json(*args) -> String (3019.0)

自身を JSON 形式の文字列に変換して返します。

...にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 引数はそのまま JSON::Generator::GeneratorMethods::Hash#to_json に渡されます。

//emlist[例][ruby]{
require "json/add/core"

begin
0/0
re...
...scue => e
e.to_json # => "{\"json_class\":\"ZeroDivisionError\",\"m\":\"divided by 0\",\"b\":[\"/path/to/test.rb:4:in `/'\",\"/path/to/test.rb:4:in `<main>'\"]}"
end
//}

@see JSON::Generator::GeneratorMethods::Hash#to_json...