Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: "1".to_i *2 == 1 && "1".to_i*2 == 2 ?
Paolo Negri
9/30/2006 12:03:00 AM
because the second version converts the given string in base 2.
to_i accept an optional parameter which is the base of the integer (by
default 10)
http://www.ruby-doc.org/core/classes/String.ht...
'1'.to_i*2 calls the method * applied to the value returned by to_i
'1'.to_i *2 is like '1'.to_i(*2)
anyway a more common way to write the expression is
'1'.to_i * 2
Paolo
On 30/09/06, Giovanni Intini <intinig@gmail.com> wrote:
> Can anyone explain to me why
>
> "1".to_i*2 is equal to 2
> and
> "1".to_i *2 is equale to 1?
>
> Thanks
> Giovanni
>
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: "1".to_i *2 == 1 && "1".to_i*2 == 2 ?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password