From: James Gallagher Date: 2011-11-30T23:30:02+09:00 Subject: Re: Stupid question Mr Jaba wrote in post #1034419: > I'm sure someone will come up with a better solution, but a quick and > dirty > way would be to convert it to a string then split it: > > 2011.to_s.split(//).inject(0){|sum, a| sum + a.to_i} > > Like I say, not the cleanest, but it works. Hope that helps. Thank you. That really helps. :-) -- Posted via http://www.ruby-forum.com/.