別のキーワード
ライブラリ
- ビルトイン (1281)
- abbrev (12)
-
cgi
/ core (12) - csv (39)
- date (4)
- erb (8)
- json (108)
-
json
/ add / bigdecimal (12) -
json
/ add / complex (12) -
json
/ add / date (12) -
json
/ add / date _ time (12) -
json
/ add / exception (12) -
json
/ add / range (12) -
json
/ add / rational (12) -
json
/ add / regexp (12) -
json
/ add / struct (12) -
json
/ add / time (12) -
net
/ http (72) - open-uri (12)
- optparse (36)
- ostruct (14)
- rake (24)
-
rexml
/ document (48) - tsort (93)
-
webrick
/ httprequest (12)
クラス
- Array (113)
- BigDecimal (12)
- CGI (12)
-
CSV
:: Row (15) -
CSV
:: Table (24) - Complex (12)
- Data (9)
- Date (14)
- DateTime (14)
- ERB (8)
-
Encoding
:: Converter (48) - Exception (12)
- Float (12)
- Hash (607)
- MatchData (14)
- Method (12)
- Module (12)
- Numeric (12)
- Object (24)
- OpenStruct (14)
- OptionParser (24)
-
REXML
:: Attributes (12) -
REXML
:: DocType (12) -
REXML
:: Element (24) -
Rake
:: TaskArguments (24) - Range (24)
- Rational (12)
- Regexp (36)
-
RubyVM
:: InstructionSequence (12) - String (240)
- Struct (59)
- Time (14)
- UnboundMethod (24)
-
WEBrick
:: HTTPRequest (12)
モジュール
- Enumerable (69)
-
JSON
:: Generator :: GeneratorMethods :: Array (12) -
JSON
:: Generator :: GeneratorMethods :: FalseClass (12) -
JSON
:: Generator :: GeneratorMethods :: Float (12) -
JSON
:: Generator :: GeneratorMethods :: Hash (12) -
JSON
:: Generator :: GeneratorMethods :: Integer (12) -
JSON
:: Generator :: GeneratorMethods :: NilClass (12) -
JSON
:: Generator :: GeneratorMethods :: Object (12) -
JSON
:: Generator :: GeneratorMethods :: String (12) -
JSON
:: Generator :: GeneratorMethods :: TrueClass (12) -
Net
:: HTTPHeader (72) -
OpenURI
:: Meta (12) -
OptionParser
:: Arguable (12) - TSort (93)
キーワード
- % (12)
- < (10)
- <= (10)
- == (12)
- === (12)
- > (10)
- >= (10)
- abbrev (12)
-
add
_ attributes (12) -
add
_ element (12) - collect (28)
-
compare
_ by _ identity (12) -
compare
_ by _ identity? (12) -
deconstruct
_ keys (20) -
default
_ proc (12) -
default
_ proc= (12) -
delete
_ if (12) - difference (7)
- dig (20)
- each (12)
-
each
_ key (12) -
each
_ pair (12) -
each
_ strongly _ connected _ component (23) -
each
_ strongly _ connected _ component _ from (23) -
each
_ value (12) - encode (36)
- entities (12)
- eql? (48)
- equal? (12)
- fetch (36)
- filter (14)
- filter! (14)
- flatten (12)
-
form
_ data= (12) - getopts (36)
-
group
_ by (12) - gsub (48)
- gsub! (48)
- header (12)
- inspect (12)
- intersection (6)
- invert (12)
-
keep
_ if (19) - length (12)
- map (28)
- merge (24)
- merge! (24)
-
named
_ captures (24) - namespaces (12)
- owner (12)
-
primitive
_ convert (48) - query (12)
- reject (24)
- reject! (24)
- replace (12)
- result (8)
-
ruby2
_ keywords (12) - select (19)
- select! (19)
-
set
_ form _ data (12) - size (12)
- store (12)
-
strongly
_ connected _ components (12) - sub (36)
- sub! (36)
- tally (10)
-
to
_ a (24) -
to
_ csv (12) -
to
_ h (74) -
to
_ hash (24) -
to
_ json (228) -
to
_ proc (10) -
to
_ s (24) -
transform
_ keys (20) -
transform
_ keys! (20) -
transform
_ values (18) -
transform
_ values! (18) - tsort (12)
-
tsort
_ each (23) -
type
_ params (12) - union (7)
- update (24)
-
with
_ defaults (12) - | (12)
検索結果
先頭5件
-
Hash
# hash -> Integer (27326.0) -
自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。 自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
...自身が保持するキーと値のハッシュ値を元にして算出した整数を返します。
自身が保持するキーや値が変化すればこのメソッドが返す値も変化します。
//emlist[例][ruby]{
a = {}
p a.hash #=> 0
a[1] = :x
p a.hash #=> 329543
//}... -
String
# hash -> Integer (24338.0) -
self のハッシュ値を返します。 eql? で等しい文字列は、常にハッシュ値も等しくなります。
...self のハッシュ値を返します。
eql? で等しい文字列は、常にハッシュ値も等しくなります。
//emlist[例][ruby]{
"test".hash # => 4038258770210371295
("te" + "st").hash == "test".hash # => true
//}
@see Hash... -
Struct
# hash -> Integer (24326.0) -
self が保持するメンバのハッシュ値を元にして算出した整数を返します。 self が保持するメンバの値が変化すればこのメソッドが返す値も変化します。
...返す値も変化します。
//emlist[例][ruby]{
Dog = Struct.new(:name, :age)
dog = Dog.new("fred", 5)
p dog.hash #=> 7917421
dog.name = "john"
p dog.hash #=> -38913223
//}
[注意] 本メソッドの記述は Struct の下位クラスのインスタンス......に対して呼び
出す事を想定しています。Struct.new は Struct の下位クラスを作成する点に
注意してください。... -
Object
# hash -> Integer (21468.0) -
オブジェクトのハッシュ値を返します。このハッシュ値は、Object#eql? と合わせて Hash クラスで、2つのオブジェクトを同一のキーとするか判定するために用いられます。
...オブジェクトのハッシュ値を返します。このハッシュ値は、Object#eql? と合わせて Hash クラスで、2つのオブジェクトを同一のキーとするか判定するために用いられます。
2つのオブジェクトのハッシュ値が異なるとき、直ち......して判定されます。
逆に、2つのハッシュ値が同じとき、さらに Object#eql? での比較により判定されます。
そのため、同じキーとして判定される状況は Object#eql? の比較で真となる場合のみであり、このとき前段階としてハッ......eql?(B) ならば A.hash == B.hash
の関係が満たされている必要があります。
ただし、ハッシュのキーとして Integer, Symbol, String などの特定の組み込みクラスが使われるときは、組込みのハッシュ関数が使用され、hash メソッドは呼... -
Hash
# transform _ keys(hash) -> Hash (21440.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s......) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}
@see Hash#transform_keys!
@see Hash#transform_values
@see Hash#transform_values!... -
Hash
# invert -> Hash (21350.0) -
値からキーへのハッシュを作成して返します。
...list[例][ruby]{
h = { "a" => 0, "b" => 100, "c" => 200, "d" => 300, "e" => 300 }
p h.invert #=> {0=>"a", 100=>"b", 200=>"c", 300=>"e"}
//}
=== 参考
値が重複していたときに備えて、変換後の値を配列として保持するには、次のようにします。
//emlist[][ruby]{......def safe_invert(orig_hash)
orig_hash.each_key.group_by do |key|
orig_hash[key]
end
end
p safe_invert({"a"=>1, "b"=>1, "c"=>3}) # => {1=>["a", "b"], 3=>["c"]}
//}
@see Hash#key... -
Hash
# default _ proc -> Proc | nil (21343.0) -
ハッシュのデフォルト値を返す Proc オブジェクトを返します。 ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。
...Proc オブジェクトを返します。
ハッシュがブロック形式のデフォルト値を持たない場合 nil を返します。
//emlist[例][ruby]{
h = Hash.new {|hash, key| "The #{key} not exist in #{hash.inspect}"}
p h.default #=> nil
p block = h.default_proc #=> #<Pro......c:0x0x401a9ff4>
p block.call({},:foo) #=> "The foo not exist in {}"
h = Hash.new("default")
p h.default #=> "default"
p h.default_proc #=> nil
//}
@see Hash#default... -
Hash
# transform _ keys -> Enumerator (21340.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s......) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}
@see Hash#transform_keys!
@see Hash#transform_values
@see Hash#transform_values!... -
Hash
# transform _ keys {|key| . . . } -> Hash (21340.0) -
すべてのキーに対してブロックを呼び出した結果で置き換えたハッシュを返します。 値は変化しません。
...@param hash 置き換え前のキーから置き換え後のキーへのハッシュを指定します。
//emlist[例][ruby]{
h = { a: 1, b: 2, c: 3 }
h.transform_keys {|k| k.to_s } # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys(a: "a", d: "d") # => {"a"=>1, :b=>2, :c=>3}
h.transform_keys(&:to_s......) # => {"a"=>1, "b"=>2, "c"=>3}
h.transform_keys.with_index {|k, i| "#{k}.#{i}" }
# => {"a.0"=>1, "b.1"=>2, "c.2"=>3}
//}
@see Hash#transform_keys!
@see Hash#transform_values
@see Hash#transform_values!... -
Array
# hash -> Integer (21338.0) -
自身のハッシュ値を整数で返します。ハッシュ値は自身の各要素のハッシュ値から 計算されます。Array#eql? で比較して等しい配列同士は同じハッシュ値を返します。
...ら
計算されます。Array#eql? で比較して等しい配列同士は同じハッシュ値を返します。
//emlist[例][ruby]{
a = ["a", "b", 1]
a.hash #=> 321
b = a.dup
b.hash #=> 321
["a", 1, "b"].hash #=> 491
["a", 1.0, "b"].hash #=> 466227
//}... -
Data
# hash -> Integer (21338.0) -
自身のハッシュ値を整数で返します。 Data#eql? で比較して等しいオブジェクトは同じハッシュ値を返します。
...Data#eql? で比較して等しいオブジェクトは同じハッシュ値を返します。
//emlist[例][ruby]{
Dog = Data.define(:name, :age)
dog1 = Dog.new("Fred", 5)
p dog1.hash # => -3931425561194935428
dog2 = Dog.new("Fred", 5)
p dog2.hash # => -3931425561194935428
dog3 = Dog.new("Fred",......6)
p dog3.hash # => -4469132459285820530
//}
[注意] 本メソッドの記述は Data のサブクラスのインスタンスに対して呼び
出す事を想定しています。Data.define は Data のサブクラスを作成する点に
注意してください。
@see Object#hash... -
Hash
# reject {|key , value| . . . } -> Hash (21338.0) -
self を複製して、ブロックを評価した値が真になる要 素を削除したハッシュを返します。
...umerable#reject とほぼ同じです。
selfを破壊的に変更したい場合はかわりにHash#delete_ifかHash#reject!を使います。
//emlist[例][ruby]{
h = { 2 =>"8" ,4 =>"6" ,6 =>"4" ,8 =>"2" }
p h.reject{|key, value| key.to_i < value.to_i} #=> {6=>"4", 8=>"2"}
//}
@see Hash#delete_......if,Hash#delete,Enumerable#reject...