From: "Paul D. Kraus" Date: 2006-06-06T05:00:31+09:00 Subject: Object Troubles - undefined method `+' ------=_Part_39680_10872170.1149537627752 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline I am parsing a text file that is 3 fields per line deliminted by pipes '|' Each line contains a customer code, shipmethod, and customer name. Each line represents an invoice that was cut. I need to count all invoices and then count all invoices that went out next day air saver. From working with the pick axe it seems to me that you have a class with two attributes invoice, and nda invoice. You then store your objects in a hash for easy lookup. When i run the below program I get this error... ./parse.rb:14:in `incndainvoice': undefined method `+' for nil:NilClass (NoMethodError) from ./parse.rb:31 from ./parse.rb:20 TIA, Paul Here is my class and program ... #!/usr/bin/env ruby class Customer attr_reader :invoices, :ndainvoices attr_writer :invoices, :ndainvoices def initialize @invoices = 1 @ndainvoices = 0 end def increment_invoice invoices = invoices + 1 end def increment_ndainvoice ndainvoice = ndainvoice + 1 end end customers = Hash.new open('NdaInvoiceCount.txt','r').each_line do |line| (customer_code, ship_method, customer_name) = line.chomp.split('|') if customers[ customer_code ] customers[ customer_code ].increment_invoice else customers[ customer_code ] = Customer.new end customers[ customer_code ].increment_ndainvoice if ship_method == 'SAVGRD' end here is some sample data.... 0000016324|SAVGRD|Dupage Prosthetics 0000038955|SAVGRD|TRUDELL ORTH & PROS SERVICES 0000019155|UPS |Scott Orthotic Labs 0000061674|UPS |COMPREHENSIVE BRACE & LIMB CTR LLC 0000008593|U02G |Huron Valley Assoc 0000039954|SAVGRD|Island Coast Orthopedics 0000028719|UPS |Paul Richelson's Feet First 0000003455|FEDGND|CLARK ORTH 0000019297|UPS |J. Slawner LTD. 0000061508|UPS |LEVY & RAPPEL ------=_Part_39680_10872170.1149537627752--