From: ideal one Date: 2011-10-15T06:54:13+09:00 Subject: Re: Ruby functions to split numbers Ian M. Asaff wrote in post #1026669: > ruby-1.9.2-p290 :010 > a = "01234567" > => "01234567" > ruby-1.9.2-p290 :011 > var1,var2 = [a[0,3],a[3,5]] > => ["012", "34567"] > ruby-1.9.2-p290 :012 > var1 > => "012" > ruby-1.9.2-p290 :013 > var2 > => "34567" > > keep in mind that a number with a leading zero makes ruby think the base > is > octal: > > ruby-1.9.2-p290 :019 > 012 > => 10 > > hope that helps. > > ian Hello there, How can i auto increment the number, i tried doing something like this... var1 is always constant, but i want to autoincrement var2 value = var2 + 1 # iam getting Cannot convert Fixnum to String Error. is something like this works var2++, not tried this in ruby. Preserve leading Zero and also autoincrement.. Cheers -- Posted via http://www.ruby-forum.com/.