From: Matt Mongeau Date: 2013-03-10T05:05:47+09:00 Subject: Re: type casting and connversion in ruby --047d7b34387aba180504d7836fd9 Content-Type: text/plain; charset=ISO-8859-1 "12".to_i #=> 12 This is creating a brand new object so this is conversion. Ruby does not support casting. On Sat, Mar 9, 2013 at 2:56 PM, Kumar R. wrote: > In programming world type casting and type conversion has completely > different meaning we all know. Now in ruby's world which it supports? > Does ruby supports both or either of them? > > With the below code what it did - casting or conversion? > > "12".to_i #=> 12 > "abc12".to_i #=> 0 > "12".to_i.class #=> Fixnum > "abc12".to_i.class #=> Fixnum > 12.to_s.class #=> String > > If it supports both as like C then please provide me some examples for > casting and conversion too. > > -- > Posted via http://www.ruby-forum.com/. > > --047d7b34387aba180504d7836fd9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
"12".to_i #=3D> 12

This is creating a brand new object so this is conversi= on.

Ruby does not support casti= ng.


On Sat, Mar 9, 2013 at 2:56 PM, Kumar R. <lists@ruby-forum.com= > wrote:
In programming world type casting and type c= onversion has completely
different meaning we all know. Now in ruby's world which it supports? Does ruby supports both or either of them?

With the below code what it did - casting or conversion?

"12".to_i #=3D> 12
"abc12".to_i #=3D> 0
"12".to_i.class #=3D> Fixnum
"abc12".to_i.class #=3D> Fixnum
12.to_s.class #=3D> String

If it supports both as like C then please provide me some examples for
casting and conversion too.

--
Posted via http://= www.ruby-forum.com/.


--047d7b34387aba180504d7836fd9--