From: daz Date: 2003-05-20T00:57:32+09:00 Subject: Re: ruby-dev summary #20159-20200 "Joel VanderWerf" wrote > How about using class.name as a fallback, so that Floats and Integers > get sorted together? > > p [1, "1", 1.5, 2].sort { |x, y| > begin > x <=> y > rescue NoMethodError > x.class.name <=> y.class.name > end > } > > Unfortunately, the rescue clause doesn't actually catch the > NoMethodError. Am I doing something wrong? (ruby-1.7.3) > > p [1, "1", 1.5, 2].sort { |x, y| begin x <=> y rescue TypeError # ^ x.class.name <=> y.class.name end } daz