One of the most fundamental and important types in the ruby programming language is the hash.
Intro to ruby hashes lab.
Objectives use a hashing program to verify the integrity of data.
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.
Fork and clone this lab and run the test suite with the learn command.
If we create a file that reads.
Monkey patching is the practice of re opening and modifying pre existing classes.
Contribute to learn co students phrg ruby intro to hashes lab pca 000 development by creating an account on github.
So ruby already has a hash class the instances of which you ve been working with in the past two units.
Pay attention to the test suite for this lab.
In past versions of ruby you could not rely on hashes maintaining order.
Since ruby 1 9 hashes maintain the order in which they re stored.
This is called monkey patching.
Enjoy the videos and music you love upload original content and share it all with friends family and the world on youtube.
A note on hash order.
Red font color or gray highlights indicate text that appears in the answers copy only.
The instructions and comments are designed to help you get the tests to pass.
Employee salary.
Then a few years back a new syntax was introduced.
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.
1 2 1 3 lab compare data with a hash answers lab compare data with a hash answers version answers note.
In this lab you ll be modifying ruby s hash class.
Class hash some.
Background scenario it is important to understand when continue reading.
As of ruby 1 9 the order of putting things into the hash is maintained.
Ruby hashes a hash is a collection of key value pairs like this.
It is a simple and flexible way to store structured values together and hashes are used all over the.
Access and modify data stored in a hash.
It is similar to an array except that indexing is done via arbitrary keys of any.
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.