From: Robert Klemme Date: 2008-02-07T07:14:56+09:00 Subject: Re: How to add string objects to hash? On 05.02.2008 08:07, dare ruby wrote: > I have created a string buffer. What exactly do you mean by that? There is String and StringIO - why create another class that can hold strings? > I have read character by character from buffer using a method and stored > in a string object > like, > > @test = String.new This does not store anything in a String object. It just creates a new empty String. > The method iteration process continues till @flag=1. So for every > iteration of method a string object(@test) is returned from the method. Why? What is the purpose of all this? > Now i want to move this returned string object @test into a hash. How > can i move string objects into hash. What exactly do you mean by "move"? You can put Strings into a Hash - as keys and values. But why? > I need to store all strings that are returned(@test) till flag=1 in a > hash. I dont want to use an array to store the values. Why not an Array? A Hash will loose the insertion order. > Please help me to do this process. Please provide enough information that someone can come up with proper suggestions. Regards robert