From: Florian Gross Date: 2005-03-24T09:39:50+09:00 Subject: Re: Credit Card Verification as an exercise Ben Giddings wrote: > Florian Gross wrote: > >> case card_type >> when 'visa' then >> [13, 16].include?(digit_length) and number[0, 1] == "4" >> when 'mastercard' then >> digit_length == 16 and ("51" .. "55").include?(number[0, 2]) >> when 'amex' then >> digit_length == 15 and %w(34 37).include?(number[0, 2]) >> when 'discover' then >> digit_length == 16 and number[0, 4] == "6011" >> end >> > > Actually, you don't need the "then"s either (and you should probably > have an else, even though nil is "untrue" as well) I know, but I somehow think it looks more balanced that way. Though I was not sure whether to use "then" or ":" in this case -- I guess it is a matter of taste and not too important. :)