Add new data to a hash.
Intro to ruby hashes lab.
Background scenario it is important to understand when continue reading.
1 2 1 3 lab compare data with a hash answers lab compare data with a hash answers version answers note.
Ruby hashes a hash is a collection of key value pairs like this.
Since ruby 1 9 hashes maintain the order in which they re stored.
It is a simple and flexible way to store structured values together and hashes are used all over the.
As of ruby 1 9 the order of putting things into the hash is maintained.
Then a few years back a new syntax was introduced.
Many ruby programmers love to use it because it takes a little less space and it also looks a lot.
One of the most fundamental and important types in the ruby programming language is the hash.
Enjoy the videos and music you love upload original content and share it all with friends family and the world on youtube.
If we create a file that reads.
A note on hash order.
What is monkey patching.
Class hash some.
The instructions and comments are designed to help you get the tests to pass.
Monkey patching is the practice of re opening and modifying pre existing classes.
Up to a certain version of ruby the syntax that uses hash rockets was the only syntax to create hashes and it works the same for all hashes no matter what kinds of objects you use as keys.
Objectives use a hashing program to verify the integrity of data.
Employee salary.
This is kind of weird because computer science 101 you re used to the fact that hashes or in other languages called maps or dictionaries the order of putting stuff in there is not maintained.
So ruby already has a hash class the instances of which you ve been working with in the past two units.
It is similar to an array except that indexing is done via arbitrary keys of any.
In past versions of ruby you could not rely on hashes maintaining order.
It s important that you know this because if you are ever working with an older version of ruby anything before ruby 1 9 you cannot rely on the hashes being in any specific order.
In this lab you ll be modifying ruby s hash class.
Red font color or gray highlights indicate text that appears in the answers copy only.
Contribute to learn co students phrg ruby intro to hashes lab pca 000 development by creating an account on github.
Access and modify data stored in a hash.