From: Matthew Rudy Date: 2007-09-19T00:03:20+09:00 Subject: Re: converting text John Joyce wrote: > On Sep 18, 2007, at 9:48 AM, Analogy Analogy wrote: > >> [1.80%, 14.50%, ruby, 3.10%] > Those are not numbers. > They will be strings. > If you want numbers you'll need to do some work to first remove the % > characters and then convert them to_f (because they're conceptually > floats) After that Ruby will by default lop off the trailing 0's > But you won't have that % character on them. > If you need to use that format and use it a lot, create a class for > them. I believe String#to_f lops off any trailing characters. ie. "1.80%".to_f -> 1.8, it does on my windows install of 1.8.5 at least. -- Posted via http://www.ruby-forum.com/.