From: Glen Holcomb Date: 2007-09-12T00:58:45+09:00 Subject: Re: undefined method `+' for nil:NilClass (NoMeth ------=_Part_24573_5779037.1189526317785 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/11/07, Glen Holcomb wrote: > > I would avoid the globals as much as possible. You also need to rename > Array to be something other than the class name of array. Try something > like: > > my_array.each do |char| > join(char) > end > > def join(char) > $TEXT = $Oldtext3 + $Oldtext2 + $Oldtext + char > end > > This is going to need more work to do what you want though. > > > > On 9/11/07, Glen Holcomb wrote: > > > > I don't see $JOB being defined anywhere. > > > > On 9/11/07, Mahen Surinam wrote: > > > > > > Dear All, > > > > > > Am trying to create a character generator in RUBY. it will create > > > characters from a-z in the folowing way: > > > > > > a > > > b > > > c > > > z > > > aa > > > ab > > > ac > > > > > > and so on. sor here is my first code: > > > > > > > > > Array = ['a', 'b', 'c' ,'d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', > > > 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] > > > > > > $Text = ""; > > > $OldText = ""; > > > $OldText2 = "" > > > $OldText3 = "" > > > > > > def Join() > > > $Text = $Oldtext3 + $OldText2 + $OldText + $JOB > > > end > > > > > > while (1) > > > Array.each do |$JOB| > > > Join() > > > puts $Text > > > end > > > end > > > > > > > > > > > > Eventually, $oldtext2-3 will be filled in later, bt am geting this > > > error: > > > > > > C:/WINDOWS/thread.rb:10:in `Join': undefined method `+' for > nil:NilClass > > > (NoMeth > > > odError) > > > from C:/WINDOWS/thread.rb:15 > > > from C:/WINDOWS/thread.rb:14:in `each' > > > from C:/WINDOWS/thread.rb:14 > > > > > > C:\WINDOWS> > > > > > > > > > > > > > > > > > > Could someone please shed some light > > > -- > > > Posted via http://www.ruby-forum.com/. > > > > > > > > > > > > -- > > "Hey brother Christian with your high and mighty errand, Your actions > > speak so loud, I can't hear a word you're saying." > > > > -Greg Graffin (Bad Religion) > > > > > -- > "Hey brother Christian with your high and mighty errand, Your actions > speak > so loud, I can't hear a word you're saying." > > -Greg Graffin (Bad Religion) > Sorry my email is acting up. This should get what you want (I think) array = [] char = "a" 0.upto(25) do array << char array << array[0] + char char = char.next end That is assuming you wanted to just get a..z and aa..az if you want the rest of the two letter combos a little tweaking should yield that. -- "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can't hear a word you're saying." -Greg Graffin (Bad Religion) ------=_Part_24573_5779037.1189526317785--