Documentation / @blazetrails/activesupport / OrderedHash
Class: OrderedHash<K, V>
Defined in: packages/activesupport/lib/ordered-hash.ts:15
Extends
Hash<K,V>
Type Parameters
| Type Parameter |
|---|
K |
V |
Constructors
Constructor
new OrderedHash<
K,V>(entries?):OrderedHash<K,V>
Defined in: packages/activesupport/lib/ordered-hash.ts:16
Parameters
| Parameter | Type |
|---|---|
entries? | Iterable<readonly [K, V], any, any> |
Returns
OrderedHash<K, V>
Overrides
Hash<K, V>.constructor
Properties
[toStringTag]
readonly[toStringTag]:string
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:135
Inherited from
Hash.[toStringTag]
size
readonlysize:number
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts:46
Returns
the number of elements in the Map.
Inherited from
Hash.size
[species]
readonlystatic[species]:MapConstructor
Defined in: node_modules/.pnpm/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:317
Inherited from
Hash.[species]
Methods
[iterator]()
[iterator]():
Generator<[K,V],undefined,unknown>
Defined in: packages/ruby-compat/dist/hash.d.ts:677
rb_hash_foreach (vendor/ruby/v3.3.11/hash.c:1438), the walk every yielding Hash method goes through: it raises the receiver's iter_lev for the length of the walk and lowers it in an ensure. A for…of that ends, breaks or throws closes the iterator and lowers the level. One left part-way keeps it raised, as a suspended hash.each Enumerator does.
Returns
Generator<[K, V], undefined, unknown>
No Rails Equivalent
PERMANENT — Ruby core rb_hash_foreach (vendor/ruby/v3.3.11/hash.c:1438).
Inherited from
Hash.[iterator]
assoc()
assoc(
key): [K,V] |null
Defined in: packages/ruby-compat/dist/hash.d.ts:914
Hash#assoc (vendor/ruby/v3.3.11/hash.c:4193 rb_hash_assoc): the stored key and its value for key, else nil.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
[K, V] | null
No Rails Equivalent
PERMANENT
Inherited from
Hash.assoc
clear()
clear():
void
Defined in: packages/ruby-compat/dist/hash.d.ts:568
Hash#clear (vendor/ruby/v3.3.11/hash.c:1988 rb_hash_clear), which also begins with rb_hash_modify_check.
Returns
void
No Rails Equivalent
PERMANENT — Ruby core Hash#clear (vendor/ruby/v3.3.11/hash.c:1988).
Inherited from
Hash.clear
compact()
compact():
Hash<K,NonNullable<V>>
Defined in: packages/ruby-compat/dist/hash.d.ts:951
Hash#compact (vendor/ruby/v3.3.11/hash.c:4360 rb_hash_compact): a dup with every nil value dropped (delete_if_nil).
Returns
Hash<K, NonNullable<V>>
No Rails Equivalent
PERMANENT
Inherited from
Hash.compact
compactBang()
compactBang():
OrderedHash<K,V> |null
Defined in: packages/ruby-compat/dist/hash.d.ts:957
Hash#compact! (vendor/ruby/v3.3.11/hash.c:4385 rb_hash_compact_bang).
Returns
OrderedHash<K, V> | null
No Rails Equivalent
PERMANENT
Inherited from
Hash.compactBang
compareByIdentity()
compareByIdentity():
this
Defined in: packages/ruby-compat/dist/hash.d.ts:667
Hash#compare_by_identity (vendor/ruby/v3.3.11/hash.c:4427rb_hash_compare_by_id): keys are compared by identity from here on, and the receiver is returned. The rehash into an identhash table keeps every entry, since two stored keys were never eql?, so only the eql? index goes. A JS string is a primitive with no identity apart from its value, so two equal Strings stay one key where Ruby makes them two.
Returns
this
No Rails Equivalent
PERMANENT — Ruby core Hash#compare_by_identity (vendor/ruby/v3.3.11/hash.c:4427).
Inherited from
Hash.compareByIdentity
deconstructKeys()
deconstructKeys(
_keys):this
Defined in: packages/ruby-compat/dist/hash.d.ts:964
Hash#deconstruct_keys (vendor/ruby/v3.3.11/hash.c:4759rb_hash_deconstruct_keys): the receiver itself.
Parameters
| Parameter | Type |
|---|---|
_keys | unknown |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.deconstructKeys
default()
default(...
key):V|undefined
Defined in: packages/ruby-compat/dist/hash.d.ts:577
Hash#default (vendor/ruby/v3.3.11/hash.c:2238 rb_hash_default), both arms: with no argument the stored default value — nil when a default_proc is what is stored — and with a key the proc's result for that key.
Parameters
| Parameter | Type |
|---|---|
...key | [] | [K] |
Returns
V | undefined
No Rails Equivalent
PERMANENT — Ruby core Hash#default (vendor/ruby/v3.3.11/hash.c:2238).
Inherited from
Hash.default
defaultProc()
defaultProc():
DefaultProc<K,V> |undefined
Defined in: packages/ruby-compat/dist/hash.d.ts:615
Hash#default_proc (vendor/ruby/v3.3.11/hash.c:2285 rb_hash_default_proc): the proc only when one is what is stored.
Returns
DefaultProc<K, V> | undefined
No Rails Equivalent
PERMANENT — Ruby core Hash#default_proc (vendor/ruby/v3.3.11/hash.c:2285).
Inherited from
Hash.defaultProc
delete()
delete(
key,block?):any
Defined in: packages/ruby-compat/dist/hash.d.ts:633
Hash#delete (vendor/ruby/v3.3.11/hash.c:2441 rb_hash_delete_m): returns the deleted value, the block's result for a key that was not there, nil otherwise. Map#delete returns a boolean instead, and a TS override may not narrow a boolean return, so the declared return is MapBoundaryReturn — the dynamic return Ruby has here.
Parameters
| Parameter | Type |
|---|---|
key | K |
block? | (key) => V |
Returns
any
No Rails Equivalent
PERMANENT — Ruby core Hash#delete (vendor/ruby/v3.3.11/hash.c:2441).
Inherited from
Hash.delete
deleteIf()
deleteIf(
block):this
Defined in: packages/ruby-compat/dist/hash.d.ts:769
Hash#delete_if (vendor/ruby/v3.3.11/hash.c:2564 rb_hash_delete_if): drops every pair the block answers truthily for, and returns the receiver.
Parameters
| Parameter | Type |
|---|---|
block | (key, value) => unknown |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.deleteIf
dig()
dig(
key, ...rest):unknown
Defined in: packages/ruby-compat/dist/hash.d.ts:922
Hash#dig (vendor/ruby/v3.3.11/hash.c:4627 rb_hash_dig): self[key], then rb_obj_dig (vendor/ruby/v3.3.11/object.c:3906) over the rest, which answers nil through a nil and sends dig to anything else.
Parameters
| Parameter | Type |
|---|---|
key | K |
...rest | unknown[] |
Returns
unknown
No Rails Equivalent
PERMANENT
Inherited from
Hash.dig
each()
Call Signature
each():
MapIterator<[K,V]>
Defined in: packages/activesupport/lib/ordered-hash.ts:172
Ruby core Hash#each, defined as rb_hash_each_pair (vendor/ruby/v3.3.11/hash.c:7219).
Returns
MapIterator<[K, V]>
No Rails Equivalent
PERMANENT
Overrides
Hash.each
Call Signature
each(
block):this
Defined in: packages/activesupport/lib/ordered-hash.ts:173
Ruby core Hash#each, defined as rb_hash_each_pair (vendor/ruby/v3.3.11/hash.c:7219).
Parameters
| Parameter | Type |
|---|---|
block | (key, value) => void |
Returns
this
No Rails Equivalent
PERMANENT
Overrides
Hash.each
eachKey()
Call Signature
eachKey():
MapIterator<K>
Defined in: packages/activesupport/lib/ordered-hash.ts:144
Ruby core Hash#each_key (vendor/ruby/v3.3.11/hash.c:3098), inherited by OrderedHash < ::Hash.
Returns
MapIterator<K>
No Rails Equivalent
PERMANENT
Call Signature
eachKey(
block):this
Defined in: packages/activesupport/lib/ordered-hash.ts:145
Ruby core Hash#each_key (vendor/ruby/v3.3.11/hash.c:3098), inherited by OrderedHash < ::Hash.
Parameters
| Parameter | Type |
|---|---|
block | (key) => void |
Returns
this
No Rails Equivalent
PERMANENT
eachPair()
Call Signature
eachPair():
MapIterator<[K,V]>
Defined in: packages/activesupport/lib/ordered-hash.ts:158
Ruby core Hash#each_pair (vendor/ruby/v3.3.11/hash.c:3149), inherited by OrderedHash < ::Hash.
Returns
MapIterator<[K, V]>
No Rails Equivalent
PERMANENT
Call Signature
eachPair(
block):this
Defined in: packages/activesupport/lib/ordered-hash.ts:159
Ruby core Hash#each_pair (vendor/ruby/v3.3.11/hash.c:3149), inherited by OrderedHash < ::Hash.
Parameters
| Parameter | Type |
|---|---|
block | (key, value) => void |
Returns
this
No Rails Equivalent
PERMANENT
eachValue()
Call Signature
eachValue():
MapIterator<V>
Defined in: packages/activesupport/lib/ordered-hash.ts:130
Ruby core Hash#each_value (vendor/ruby/v3.3.11/hash.c:3060), inherited by OrderedHash < ::Hash.
Returns
MapIterator<V>
No Rails Equivalent
PERMANENT
Call Signature
eachValue(
block):this
Defined in: packages/activesupport/lib/ordered-hash.ts:131
Ruby core Hash#each_value (vendor/ruby/v3.3.11/hash.c:3060), inherited by OrderedHash < ::Hash.
Parameters
| Parameter | Type |
|---|---|
block | (value) => void |
Returns
this
No Rails Equivalent
PERMANENT
encodeWith()
encodeWith(
coder):void
Defined in: packages/activesupport/lib/ordered-hash.ts:25
Parameters
| Parameter | Type |
|---|---|
coder | Coder |
Returns
void
entries()
entries():
Generator<[K,V],undefined,unknown>
Defined in: packages/ruby-compat/dist/hash.d.ts:685
Map#entries, the pair walk under another name, so it goes through rb_hash_foreach (vendor/ruby/v3.3.11/hash.c:1438) as Hash#each_pair does (hash.c:3149).
Returns
Generator<[K, V], undefined, unknown>
No Rails Equivalent
PERMANENT — Ruby core Hash#each_pair (vendor/ruby/v3.3.11/hash.c:3149).
Inherited from
Hash.entries
except()
except(...
keys):Hash<K,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:894
Hash#except (vendor/ruby/v3.3.11/hash.c:2683 rb_hash_except); the body is except's.
Parameters
| Parameter | Type |
|---|---|
...keys | K[] |
Returns
Hash<K, V>
No Rails Equivalent
PERMANENT
Inherited from
Hash.except
fetch()
fetch(
key, ...rest):unknown
Defined in: packages/ruby-compat/dist/hash.d.ts:810
Hash#fetch (vendor/ruby/v3.3.11/hash.c:2176 rb_hash_fetch_m); the body is fetch's.
Parameters
| Parameter | Type |
|---|---|
key | K |
...rest | unknown[] |
Returns
unknown
No Rails Equivalent
PERMANENT
Inherited from
Hash.fetch
fetchValues()
fetchValues(...
argv):V[]
Defined in: packages/ruby-compat/dist/hash.d.ts:929
Hash#fetch_values (vendor/ruby/v3.3.11/hash.c:2745rb_hash_fetch_values): rb_hash_fetch for each key.
Parameters
| Parameter | Type |
|---|---|
...argv | K[] |
Returns
V[]
No Rails Equivalent
PERMANENT
Inherited from
Hash.fetchValues
flatten()
flatten(...
argv):unknown[]
Defined in: packages/ruby-compat/dist/hash.d.ts:944
Hash#flatten (vendor/ruby/v3.3.11/hash.c:4308 rb_hash_flatten): the pairs spliced into one Array, then flatten!(level - 1) over it, or a recursive flatten! for a negative level.
Parameters
| Parameter | Type |
|---|---|
...argv | [] | [number] |
Returns
unknown[]
No Rails Equivalent
PERMANENT
Inherited from
Hash.flatten
forEach()
forEach(
callbackfn,thisArg?):void
Defined in: packages/ruby-compat/dist/hash.d.ts:692
Map#forEach, walked through rb_hash_foreach (vendor/ruby/v3.3.11/hash.c:1438) as Hash#each_pair is (hash.c:3149).
Parameters
| Parameter | Type |
|---|---|
callbackfn | (value, key, map) => void |
thisArg? | unknown |
Returns
void
No Rails Equivalent
PERMANENT — Ruby core Hash#each_pair (vendor/ruby/v3.3.11/hash.c:3149).
Inherited from
Hash.forEach
freeze()
freeze():
this
Defined in: packages/ruby-compat/dist/hash.d.ts:501
Object#freeze (vendor/ruby/v3.3.11/object.c:1284 rb_obj_freeze), which Hash#freeze (vendor/ruby/v3.3.11/hash.c:107) is. Object.freeze cannot serve: it seals a JS object's properties, and a Map's entries are not properties, so the seat is the FL_FREEZE flag rb_hash_modify_check reads.
Returns
this
No Rails Equivalent
PERMANENT — Ruby core Object#freeze (vendor/ruby/v3.3.11/object.c:1284).
Inherited from
Hash.freeze
get()
get(
key):V|undefined
Defined in: packages/ruby-compat/dist/hash.d.ts:569
Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
V | undefined
Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.
Inherited from
Hash.get
has()
has(
key):boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:532
Hash#key? (vendor/ruby/v3.3.11/hash.c:3671 rb_hash_has_key), a lookup by the key's hash / eql?.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
boolean
No Rails Equivalent
PERMANENT — Ruby core Hash#key? (vendor/ruby/v3.3.11/hash.c:3671).
Inherited from
Hash.has
hasKey()
hasKey(
key):boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:816
Hash#key? / #has_key? (vendor/ruby/v3.3.11/hash.c:3671 rb_hash_has_key).
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
boolean
No Rails Equivalent
PERMANENT
Inherited from
Hash.hasKey
hasValue()
hasValue(
val):boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:539
Hash#has_value? (vendor/ruby/v3.3.11/hash.c:3697 rb_hash_has_value): rb_hash_search_value (:3680) compares each stored value with ==.
Parameters
| Parameter | Type |
|---|---|
val | unknown |
Returns
boolean
No Rails Equivalent
PERMANENT — Ruby core Hash#has_value? (vendor/ruby/v3.3.11/hash.c:3697).
Inherited from
Hash.hasValue
initializeCopy()
initializeCopy(
hash):this
Defined in: packages/ruby-compat/dist/hash.d.ts:700
Hash#initialize_copy, which MRI binds to rb_hash_replace (vendor/ruby/v3.3.11/hash.c:7190): the hook rbObjDup / rbObjClone dispatch, so a dup holds a copy of the receiver's table.
Parameters
| Parameter | Type |
|---|---|
hash | Hash<K, V> |
Returns
this
No Rails Equivalent
PERMANENT — Ruby core Hash#initialize_copy (vendor/ruby/v3.3.11/hash.c:7190).
Inherited from
Hash.initializeCopy
inspect()
inspect():
string
Defined in: packages/activesupport/lib/ordered-hash.ts:120
Returns
string
invert()
invert():
OrderedHash<V,K>
Defined in: packages/activesupport/lib/ordered-hash.ts:112
Ruby core Hash#invert (vendor/ruby/v3.3.11/hash.c:3900), inherited by OrderedHash < ::Hash.
Returns
OrderedHash<V, K>
No Rails Equivalent
PERMANENT
Overrides
Hash.invert
isCompareByIdentity()
isCompareByIdentity():
boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:725
Hash#compare_by_identity? (vendor/ruby/v3.3.11/hash.c:4474rb_hash_compare_by_id_p).
Returns
boolean
No Rails Equivalent
PERMANENT — Ruby core Hash#compare_by_identity? (vendor/ruby/v3.3.11/hash.c:4474).
Inherited from
Hash.isCompareByIdentity
isEmpty()
isEmpty():
boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:762
Hash#empty? (vendor/ruby/v3.3.11/hash.c:3023 rb_hash_empty_p).
Returns
boolean
No Rails Equivalent
PERMANENT
Inherited from
Hash.isEmpty
isExtractableOptions()
isExtractableOptions():
boolean
Defined in: packages/activesupport/lib/ordered-hash.ts:178
Returns
boolean
isFrozen()
isFrozen():
boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:508
Object#frozen? (vendor/ruby/v3.3.11/object.c:1301 rb_obj_frozen_p). Ruby's ? predicate suffix is is here, per the conventions.
Returns
boolean
No Rails Equivalent
PERMANENT — Ruby core Object#frozen? (vendor/ruby/v3.3.11/object.c:1301).
Inherited from
Hash.isFrozen
isInclude()
isInclude(
key):boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:525
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
boolean
No Rails Equivalent
PERMANENT — Ruby core Hash#include? (vendor/ruby/v3.3.11/hash.c:7255, rb_hash_has_key :3671).
Inherited from
Hash.isInclude
isMember()
isMember(
key):boolean
Defined in: packages/ruby-compat/dist/hash.d.ts:822
Hash#member? (vendor/ruby/v3.3.11/hash.c:7239), rb_hash_has_key.
Parameters
| Parameter | Type |
|---|---|
key | K |
Returns
boolean
No Rails Equivalent
PERMANENT
Inherited from
Hash.isMember
keepIf()
keepIf(
block):this
Defined in: packages/ruby-compat/dist/hash.d.ts:783
Hash#keep_if (vendor/ruby/v3.3.11/hash.c:2844 rb_hash_keep_if): drops every pair the block answers falsily for (keep_if_i, :2757).
Parameters
| Parameter | Type |
|---|---|
block | (key, value) => unknown |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.keepIf
key()
key(
value):K|null
Defined in: packages/ruby-compat/dist/hash.d.ts:546
Hash#key (vendor/ruby/v3.3.11/hash.c:2354 rb_hash_key): the key of the first entry whose value is == to value (key_i, :2329), else nil.
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
K | null
No Rails Equivalent
PERMANENT — Ruby core Hash#key (vendor/ruby/v3.3.11/hash.c:2354).
Inherited from
Hash.key
keys()
keys():
any
Defined in: packages/ruby-compat/dist/hash.d.ts:743
Hash#keys (vendor/ruby/v3.3.11/hash.c:3584 rb_hash_keys): an Array of the keys, where Map#keys is an iterator. A TS override may not narrow that return, so it declares MapBoundaryReturn, the same Map boundary delete meets.
Returns
any
No Rails Equivalent
PERMANENT — Ruby core Hash#keys (vendor/ruby/v3.3.11/hash.c:3584).
Inherited from
Hash.keys
length()
length():
number
Defined in: packages/ruby-compat/dist/hash.d.ts:756
Hash#length (vendor/ruby/v3.3.11/hash.c:3002 rb_hash_size).
Returns
number
No Rails Equivalent
PERMANENT
Inherited from
Hash.length
merge()
merge(
other,block?):OrderedHash<K,V>
Defined in: packages/activesupport/lib/ordered-hash.ts:84
Hash#merge (vendor/ruby/v3.3.11/hash.c:4144 rb_hash_merge), the method a :merge send finds; the body is merge's. The conflict block is the trailing argument, marked with block.
Parameters
| Parameter | Type |
|---|---|
other | OrderedHash<K, V> |
block? | (key, v1, v2) => V |
Returns
OrderedHash<K, V>
No Rails Equivalent
PERMANENT — Ruby core Hash#merge (vendor/ruby/v3.3.11/hash.c:4144).
Overrides
Hash.merge
mergeBang()
mergeBang(...
others):this
Defined in: packages/ruby-compat/dist/hash.d.ts:857
Hash#merge! (vendor/ruby/v3.3.11/hash.c:7247), defined onto rb_hash_update.
Parameters
| Parameter | Type |
|---|---|
...others | unknown[] |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.mergeBang
nestedUnderIndifferentAccess()
nestedUnderIndifferentAccess():
this
Defined in: packages/activesupport/lib/ordered-hash.ts:57
Returns
this
rassoc()
rassoc(
obj): [K,V] |null
Defined in: packages/ruby-compat/dist/hash.d.ts:936
Hash#rassoc (vendor/ruby/v3.3.11/hash.c:4254 rb_hash_rassoc): the first pair whose value is == to obj (rassoc_i), else nil.
Parameters
| Parameter | Type |
|---|---|
obj | unknown |
Returns
[K, V] | null
No Rails Equivalent
PERMANENT
Inherited from
Hash.rassoc
reject()
reject(...
args):OrderedHash<K,V>
Defined in: packages/activesupport/lib/ordered-hash.ts:51
Parameters
| Parameter | Type |
|---|---|
...args | [(key, value) => boolean] |
Returns
OrderedHash<K, V>
rejectBang()
rejectBang(...
args):OrderedHash<K,V> |null
Defined in: packages/activesupport/lib/ordered-hash.ts:61
Hash#reject! (vendor/ruby/v3.3.11/hash.c:2594 rb_hash_reject_bang): delete_if, answering nil when nothing was deleted.
Parameters
| Parameter | Type |
|---|---|
...args | [(key, value) => boolean] |
Returns
OrderedHash<K, V> | null
No Rails Equivalent
PERMANENT
Overrides
Hash.rejectBang
replace()
replace(
hash2):this
Defined in: packages/ruby-compat/dist/hash.d.ts:708
Hash#replace (vendor/ruby/v3.3.11/hash.c:2967 rb_hash_replace): the receiver takes hash2's default / default_proc (COPY_DEFAULT) and a hash_copy of its table, which is not written through a subclass's []=.
Parameters
| Parameter | Type |
|---|---|
hash2 | Record<string, unknown> | Iterable<[K, V], any, any> |
Returns
this
No Rails Equivalent
PERMANENT — Ruby core Hash#replace (vendor/ruby/v3.3.11/hash.c:2967).
Inherited from
Hash.replace
select()
select(...
args):OrderedHash<K,V>
Defined in: packages/activesupport/lib/ordered-hash.ts:45
Parameters
| Parameter | Type |
|---|---|
...args | [(key, value) => boolean] |
Returns
OrderedHash<K, V>
selectBang()
selectBang(...
args):OrderedHash<K,V> |null
Defined in: packages/activesupport/lib/ordered-hash.ts:75
Ruby core Hash#select! (vendor/ruby/v3.3.11/hash.c:2813 rb_hash_select_bang).
Parameters
| Parameter | Type |
|---|---|
...args | [(key, value) => boolean] |
Returns
OrderedHash<K, V> | null
No Rails Equivalent
PERMANENT
Overrides
Hash.selectBang
set()
set(
key,value):this
Defined in: packages/ruby-compat/dist/hash.d.ts:521
Hash#[]= (vendor/ruby/v3.3.11/hash.c:2018 rb_hash_aset), whose rb_hash_modify goes through rb_hash_modify_check (hash.c:1623).
Parameters
| Parameter | Type |
|---|---|
key | K |
value | V |
Returns
this
No Rails Equivalent
PERMANENT — Ruby core Hash#[]= (vendor/ruby/v3.3.11/hash.c:2018).
Inherited from
Hash.set
setDefault()
setDefault(
value):void
Defined in: packages/ruby-compat/dist/hash.d.ts:608
Hash#default= (vendor/ruby/v3.3.11/hash.c:2265 rb_hash_set_default), whose SET_DEFAULT clears RHASH_PROC_DEFAULT. A TS set accessor cannot share a name with the default() reader, so it takes the conventions' setX() spelling.
Parameters
| Parameter | Type |
|---|---|
value | V | undefined |
Returns
void
No Rails Equivalent
PERMANENT — Ruby core Hash#default= (vendor/ruby/v3.3.11/hash.c:2265).
Inherited from
Hash.setDefault
setDefaultProc()
setDefaultProc(
proc):void
Defined in: packages/ruby-compat/dist/hash.d.ts:623
Hash#default_proc= (vendor/ruby/v3.3.11/hash.c:2308rb_hash_set_default_proc): nil goes through SET_DEFAULT, clearing the proc; anything that is not a Proc is a TypeError.
Parameters
| Parameter | Type |
|---|---|
proc | DefaultProc<K, V> | undefined |
Returns
void
No Rails Equivalent
PERMANENT — Ruby core Hash#default_proc= (vendor/ruby/v3.3.11/hash.c:2308).
Inherited from
Hash.setDefaultProc
shift()
shift(): [
K,V] |undefined
Defined in: packages/ruby-compat/dist/hash.d.ts:656
Hash#shift (vendor/ruby/v3.3.11/hash.c:2492 rb_hash_shift): removes the first entry and returns it as a [key, value] pair, nil for an empty hash, after rb_hash_modify_check. The entry is removed directly, with no lookup of its key, as st_shift does (hash.c:2515). MRI takes it through rb_hash_foreach only while the hash is being iterated, because st_shift may not run then; a Map drops its first entry either way.
Returns
[K, V] | undefined
No Rails Equivalent
PERMANENT — Ruby core Hash#shift (vendor/ruby/v3.3.11/hash.c:2492).
Inherited from
Hash.shift
slice()
slice(...
keys):Hash<K,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:871
Hash#slice (vendor/ruby/v3.3.11/hash.c:2651 rb_hash_slice); the body is slice's.
Parameters
| Parameter | Type |
|---|---|
...keys | K[] |
Returns
Hash<K, V>
No Rails Equivalent
PERMANENT
Inherited from
Hash.slice
store()
store(
key,value):this
Defined in: packages/ruby-compat/dist/hash.d.ts:803
Hash#store (vendor/ruby/v3.3.11/hash.c:7177), rb_hash_aset.
Parameters
| Parameter | Type |
|---|---|
key | K |
value | V |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.store
toA()
toA(): [
K,V][]
Defined in: packages/ruby-compat/dist/hash.d.ts:900
Hash#to_a (vendor/ruby/v3.3.11/hash.c:3428 rb_hash_to_a).
Returns
[K, V][]
No Rails Equivalent
PERMANENT
Inherited from
Hash.toA
toArray()
toArray(): [
K,V][]
Defined in: packages/activesupport/lib/ordered-hash.ts:41
Returns
[K, V][]
toH()
Call Signature
toH():
Hash<K,V> |Record<string,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:598
Hash#to_h (vendor/ruby/v3.3.11/hash.c:3555 rb_hash_to_h). With a block, rb_hash_to_h_block (hash.c:3528): a new bare Hash of the pairs the block returns, each checked by rb_hash_set_pair (hash.c:3503). With none, the receiver itself when it IS a Hash (hash.c:3560), otherwise a hash_dup (hash.c:3562) into a bare Hash that carries the same entries and the same default / default_proc. That bare Hash is a plain object when it needs no Hash feature (README, § "When a Ruby Hash is a Hash and when it is an object").
Returns
Hash<K, V> | Record<string, V>
No Rails Equivalent
PERMANENT — Ruby core Hash#to_h (vendor/ruby/v3.3.11/hash.c:3555).
Inherited from
Hash.toH
Call Signature
toH<
K2,V2>(block):Hash<K2,V2>
Defined in: packages/ruby-compat/dist/hash.d.ts:599
Hash#to_h (vendor/ruby/v3.3.11/hash.c:3555 rb_hash_to_h). With a block, rb_hash_to_h_block (hash.c:3528): a new bare Hash of the pairs the block returns, each checked by rb_hash_set_pair (hash.c:3503). With none, the receiver itself when it IS a Hash (hash.c:3560), otherwise a hash_dup (hash.c:3562) into a bare Hash that carries the same entries and the same default / default_proc. That bare Hash is a plain object when it needs no Hash feature (README, § "When a Ruby Hash is a Hash and when it is an object").
Type Parameters
| Type Parameter |
|---|
K2 |
V2 |
Parameters
| Parameter | Type |
|---|---|
block | (key, value) => [K2, V2] |
Returns
Hash<K2, V2>
No Rails Equivalent
PERMANENT — Ruby core Hash#to_h (vendor/ruby/v3.3.11/hash.c:3555).
Inherited from
Hash.toH
toHash()
toHash():
object
Defined in: packages/ruby-compat/dist/hash.d.ts:907
Hash#to_hash (vendor/ruby/v3.3.11/hash.c:3497 rb_hash_to_hash): the receiver itself.
Returns
object
No Rails Equivalent
PERMANENT
Inherited from
Hash.toHash
toJSON()
toJSON():
Record<string,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:586
The JSON.stringify protocol: a Map's entries are not properties, so without it a Hash stringifies as {} where Hash#to_json (vendor/ruby/v3.3.11/ext/json/generator/generator.c:430 mHash_to_json) writes each pair under its key's to_s, a Symbol's being its name.
Returns
Record<string, V>
No Rails Equivalent
PERMANENT
Inherited from
Hash.toJSON
toProc()
toProc(): (
key) =>V|null|undefined
Defined in: packages/ruby-compat/dist/hash.d.ts:836
Hash#to_proc (vendor/ruby/v3.3.11/hash.c:4752 rb_hash_to_proc): a lambda answering hash[key].
Returns
(key) => V | null | undefined
No Rails Equivalent
PERMANENT
Inherited from
Hash.toProc
toYamlType()
toYamlType():
string
Defined in: packages/activesupport/lib/ordered-hash.ts:21
Returns
string
transformKeys()
transformKeys(
hash2,block?):Hash<K,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:880
Hash#transform_keys (vendor/ruby/v3.3.11/hash.c:3227 rb_hash_transform_keys): a new bare Hash keyed by hash2's mapping, else the block's result, else the key itself (transform_keys_hash_i, :3166), or by the block alone (transform_keys_i, :3182). The blockless Enumerator arm is not ported.
Parameters
| Parameter | Type |
|---|---|
hash2 | object | ((key) => NoInfer<K>) |
block? | (key) => NoInfer<K> |
Returns
Hash<K, V>
No Rails Equivalent
PERMANENT
Inherited from
Hash.transformKeys
transformKeysBang()
transformKeysBang(
hash2,block?):this
Defined in: packages/ruby-compat/dist/hash.d.ts:887
Hash#transform_keys! (vendor/ruby/v3.3.11/hash.c:3267rb_hash_transform_keys_bang).
Parameters
| Parameter | Type |
|---|---|
hash2 | object | ((key) => NoInfer<K>) |
block? | (key) => NoInfer<K> |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.transformKeysBang
transformValues()
transformValues(
block):Hash<K,V>
Defined in: packages/ruby-compat/dist/hash.d.ts:844
Hash#transform_values (vendor/ruby/v3.3.11/hash.c:3366rb_hash_transform_values): a new Hash with each value replaced by the block's result.
Parameters
| Parameter | Type |
|---|---|
block | (value) => NoInfer<V> |
Returns
Hash<K, V>
No Rails Equivalent
PERMANENT
Inherited from
Hash.transformValues
transformValuesBang()
transformValuesBang(
block):this
Defined in: packages/ruby-compat/dist/hash.d.ts:797
Hash#transform_values! (vendor/ruby/v3.3.11/hash.c:3398rb_hash_transform_values_bang).
Parameters
| Parameter | Type |
|---|---|
block | (value) => V |
Returns
this
No Rails Equivalent
PERMANENT
Inherited from
Hash.transformValuesBang
update()
update(
other,block?):this
Defined in: packages/activesupport/lib/ordered-hash.ts:96
Hash#update (vendor/ruby/v3.3.11/hash.c:4028 rb_hash_update); the body is update's.
Parameters
| Parameter | Type |
|---|---|
other | OrderedHash<K, V> |
block? | (key, v1, v2) => V |
Returns
this
No Rails Equivalent
PERMANENT
Overrides
Hash.update
values()
values():
any
Defined in: packages/ruby-compat/dist/hash.d.ts:750
Hash#values (vendor/ruby/v3.3.11/hash.c:3628 rb_hash_values): an Array of the values, where Map#values is an iterator.
Returns
any
No Rails Equivalent
PERMANENT — Ruby core Hash#values (vendor/ruby/v3.3.11/hash.c:3628).
Inherited from
Hash.values
valuesAt()
valuesAt(...
keys): (V|null|undefined)[]
Defined in: packages/ruby-compat/dist/hash.d.ts:864
Hash#values_at (vendor/ruby/v3.3.11/hash.c:2713 rb_hash_values_at): each key's rb_hash_aref, the default included.
Parameters
| Parameter | Type |
|---|---|
...keys | K[] |
Returns
(V | null | undefined)[]
No Rails Equivalent
PERMANENT
Inherited from
Hash.valuesAt
allocate()
staticallocate<T>(this):T
Defined in: packages/ruby-compat/dist/hash.d.ts:475
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
this | () => T |
Returns
T
No Rails Equivalent
PERMANENT — Ruby core Class#allocate (vendor/ruby/v3.3.11/object.c:2066).
Inherited from
Hash.allocate
from()
staticfrom<K,V>(pairs):OrderedHash<K,V>
Defined in: packages/activesupport/lib/ordered-hash.ts:32
Type Parameters
| Type Parameter |
|---|
K |
V |
Parameters
| Parameter | Type |
|---|---|
pairs | [K, V][] |
Returns
OrderedHash<K, V>