Register now or log in to join your professional community.
An array is a collection of data.Each element of an array is accessed using an integer which is the index of the element in an array.
Let's create an array, name
name = ["Shahbaz","Ramesh","Pramod"]
Now, if we want to access the elements of an array, we simply do
name[0]
=>will print 'Shahbaz'
Hash is the collection of key-value pair.In Hash, the value is accessed using the key.
let's create a hash, my_details
my_details = {'name' => 'shahbaz'}
and if, we want to access the value of hash,we simply do
my_details['name']
=>will print 'shahbaz'