Hi,

Are you having happy Christmas holidays?
I need to work without holidays, sigh.

In message "[ruby-talk:00998] Re: a question about to_i"
    on 99/12/19, "Conrad Schneiker" <schneiker / jump.net> writes:
|> I can prepare exception raising version of the conversion method, but
|> we have to decide following:
|>
|>   * the name of the method
|>
|
|Unless there are very strong arguments to the contrary, I'd recommend that
|the *non-exception-raising* version get the *new* name, and that the current
|version should raise an exception for non-numeric data.

I just remembered we already have two conversion methods!

  string.to_i
  Integer(string)

The latter is more intelligent, it understands `0x', etc prefix to
decide base radix.  So it may be good to add exception raising feature
to the latter.  e.g.

  "foo".to_i            # => 0
  Integer("foo")        # => raise exception; foo is not number
  "078".to_i            # => 78
  Integer("078")        # => raise exception; 8 is not octal number

The another option is to raise exception for non-numeric string at
every string->integer convsersion.  There's no strong reason to return
zero for non-numeric strings in Ruby.  e.g.

  "foo".to_i            # => raise exception; foo is not number
  Integer("foo")        # => raise exception; foo is not number
  "078".to_i            # => 78
  Integer("078")        # => raise exception; 8 is not octal number

What do you think about these two options?  Or other ideas?

							matz.