Thank you, Douglas. It'll take me a bit to see what your code is doing but 
I'm determined to learn. I appreciate it! 

On Sunday, June 7, 2015 at 5:53:28 AM UTC-7, Douglas Mills wrote:
>
> Hi,
>
> The key / value pairs can be iterated like this:
>
> str = ''
> contacts.each do |key, value|
>     str += key.to_s + ' : ' + value + ', '
> end 
>
> puts 'contacts output : ' + str
>
> There are more compact ways to do this but will not be as easy to see what 
> is happening.
>
> Kind Regards,
>
> Doug 
>
> On Sunday, June 7, 2015 at 8:31:44 AM UTC+1, Anonymity wrote:
>>
>> Hi Everyone,
>>
>> Here is the code I currently have:
>>
>> contacts = Hash.new
>>
>> x = 0
>> y = 0
>>
>> if x <= 5
>>     puts "What contact would you like to add?"
>>     ui = gets.chomp
>>     contacts.store(y, ui)
>>     puts "Contact added is #{contacts}"
>>     x += 1
>>     y += 1
>>     puts "X is #{x}, Y is #{y}" # so I know if the values are being 
>> incremented
>> else
>>     puts "You've reached the maximum # of contacts."
>> end
>>
>> Also, how can I print a hash to the console without a key value? 
>>
>> Thank you
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/813081e1-71ec-45cf-9a5b-4d823b30bce7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to