macrubyist (macrubyist) wrote in ruby_lang,

Quick question

If anybody's curious about why I want to do ISBN stuff for my 'hello world' program, it's in my blog.

#! /usr/bin/ruby
puts "Please enter an ISBN:"
isbn13 = gets.chomp!
isbn10 = isbn13.chop!
isbn10reverse = isbn10.reverse
# What stupid thing am I doing with the next line?
newString = 3.times { isbn10reverse.chop }
isbn10 = isbn10reverse.reverse
# do magic. This depends on looking at the prototype Applescript, figuring
# out the Ruby-ese for 'walk string throwing away non-digits as I go', and
# figuring out the Ruby-ese for the checkdigit magic that is in the
# Applescript
puts isbn10

What I want to know Now This Instant is not why it's a crap program design (which I will probably want to know in a few days' time) but why my first idea for 'chop three characters off the front' didn't work...
  • Post a new comment


    default userpic