I have a program that records the data of a person. I created the array personas = []
, empty so that when the user registers, he stores a new hash with his data inside the array personas
, thus on gets.chomp
the data is obtained one by one; example:
a = gets.chomp
persona = { nombre:a, edad:b, comuna:c, género:d }
personas.push(persona)
The thing is, I want to show the number of registered people in my other options for the client. The question is, how do I convert or display the number of hashes to an integer?
Since each person (hash) is an element within the array
personas
, you only have to display the size of the array, which you can achieve with the Array#size method :