Hi -- On Wed, 19 Jul 2006, simonh wrote: > decided to have a go at using the case statement. Why won't this work? > > ------------------------------------------------------------------------------------- > def double_it > print "Please enter a whole number (or type 'h' for help) : " > num = gets.chomp > case num > when num == 'h' > puts > puts "A whole number is 45 for example, or 12564." > puts > when num.to_i > 1 > num * num What's that for? > print num.to_s > when num.to_i <= 0 > puts "The number must be positive!" > end > end > double_it > gets Do you really mean to end with gets? As for the case statement: have a look at my previous post in this thread. The problem is that you're comparing: num with the expression: num == 'h' Then you're comparing it with the expression "num.to_i > 1", and so on. A case statement isn't a good fit here; I'd just use if/else/.../end. David -- http://www.rubypowerandlight.com => Ruby/Rails training & consultancy http://www.manning.com/black => RUBY FOR RAILS (reviewed on Slashdot, 7/12/2006!) http://dablog.rubypal.com => D[avid ]A[. ]B[lack's][ Web]log dblack / wobblini.net => me