Hashes Flashcards

1
Q

What is a hash?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what is a key in a hash?

A

in a hash there are “keys” that must be unique and cannot be duplicated. we use keys to store data in a hash.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

explain .has_key?()

A

this method is used to find if there is a certain key inside a hash. you must call the key in the parameters. dog.has_key?(“name”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

explain .has_value?()

A

this used to find the value in a hash and it will return a boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

explain hash.keys[] and hash.values[]

A

hash.keys is used to get all keys in an array. since its turned into an array you can call each array by providing an index.
hash.keys[1]

hash.values works exactly the same just targeting the values.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

explain .each_key and .each_value

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

explain =>

A

this is what programmers call the rocket. it used to give value to a key in a hash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

explain .Hash.new()

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

explain my_hash[“a”] => “yes”
what does this do?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly