[#964] Bastion or SecurityManager for Ruby? — Clemens Hintze <clemens.hintze@...>

Hi,

15 messages 1999/12/10

[#989] a question about to_i — Friedrich Dominicus <Friedrich.Dominicus@...>

Sorry, I'm quite new to ruby. But I encounterd the following problem. If

17 messages 1999/12/19

[ruby-talk:00996] Re: a question about to_i

From: matz@... (Yukihiro Matsumoto)
Date: 1999-12-19 16:18:42 UTC
List: ruby-talk #996
Hi,

In message "[ruby-talk:00989] a question about to_i"
    on 99/12/19, Friedrich Dominicus <Friedrich.Dominicus@inka.de> writes:

|Sorry, I'm quite new to ruby. But I encounterd the following problem. If
|I have a string "bla" and apply to_i to it I get 0. This seems to be
|quite strange because it is what it is a string so shouldn't an
|exeception be rissen or s.th simular. 

As Gotoken stated in [ruby-talk:00992], String#to_i (i.e. the to_i
method of the String class) always return a integer.  This is
inherited from UNIX's atoi() behavior.

I can prepare exception raising version of the conversion method, but
we have to decide following:

  * the name of the method

    what is the proper name for the exception raising integer
    conversion method of a string.

  * proper behavior

    on what situation, what kind of exception should be raised?
    in addition, some may want to retrieve non numeric trailer, 
    the other may want to specify radix.

Let's discuss about it.

I have to mention that you can define your own version of integer
conversion method easily in Ruby, like in [ruby-talk:0992] and
[ruby-talk:0993].

							matz.

In This Thread