Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manual/api/_builtin/ObjectSpace__WeakMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,11 @@ p weak_map.delete("bar") { |k| "#{k} not found" } # => "bar not found"
#@end

### def key?(key) -> bool
{: since="2.1.0"}
### def include?(key) -> bool
{: since="2.1.0"}
### def member?(key) -> bool
{: since="2.1.0"}

引数 key を参照元とするエントリを保持している場合に true を返します。

Expand All @@ -92,7 +95,9 @@ p weak_map.key?("text") # => false (内容は同じでも別オブジェクト
- **SEE** [m:ObjectSpace::WeakMap#\[\]]

### def each {|key, value| ... } -> self
{: since="2.1.0"}
### def each_pair {|key, value| ... } -> self
{: since="2.1.0"}

保持しているエントリの参照元オブジェクトと参照先オブジェクトを引数としてブロックを評価します。

Expand All @@ -115,6 +120,7 @@ weak_map.each { |k, v| p [k, v] } # => ["text", "test"]
- **SEE** [m:ObjectSpace::WeakMap#each_key], [m:ObjectSpace::WeakMap#each_value]

### def each_key {|key| ... } -> self
{: since="2.1.0"}

保持しているエントリの参照元オブジェクトを引数としてブロックを評価します。

Expand All @@ -135,6 +141,7 @@ weak_map.each_key { |k| p k } # => "text"
- **SEE** [m:ObjectSpace::WeakMap#each], [m:ObjectSpace::WeakMap#each_value]

### def each_value {|value| ... } -> self
{: since="2.1.0"}

保持しているエントリの参照先オブジェクトを引数としてブロックを評価します。

Expand All @@ -155,6 +162,7 @@ weak_map.each_value { |v| p v } # => "test"
- **SEE** [m:ObjectSpace::WeakMap#each], [m:ObjectSpace::WeakMap#each_key]

### def keys -> [object]
{: since="2.1.0"}

保持しているエントリの参照元オブジェクトからなる配列を返します。

Expand All @@ -172,6 +180,7 @@ p weak_map.keys # => ["text"]
- **SEE** [m:ObjectSpace::WeakMap#values]

### def values -> [object]
{: since="2.1.0"}

保持しているエントリの参照先オブジェクトからなる配列を返します。

Expand All @@ -189,7 +198,9 @@ p weak_map.values # => ["test"]
- **SEE** [m:ObjectSpace::WeakMap#keys]

### def size -> Integer
{: since="2.1.0"}
### def length -> Integer
{: since="2.1.0"}

保持しているエントリの数を返します。GC によって回収されたエントリは数えません。

Expand All @@ -203,6 +214,7 @@ p weak_map.length # => 1
```

### def inspect -> String
{: since="2.0.0"}

self の情報を人間に読みやすい文字列にして返します。

Expand Down