From: Henry Maddocks Date: 2012-08-06T08:16:28+09:00 Subject: Re: how perform addition a text value with an integer --Boundary_(ID_phwqHlWTnBE4SZ/LSJasqw) Content-type: text/plain; CHARSET=US-ASCII Content-transfer-encoding: 7BIT On 6/08/2012, at 11:01 AM, Fosiul Alam wrote: > > i tryed couple of ways.. but no luck > > > Integer(cuid) > cuid = cuid +1 > puts cuid > > but it through the bellow error > > `+': can't convert Fixnum into String (TypeError) Here a 'correct' version of your script. irb(main):001:0> cuid = "1008" => "1008" irb(main):002:0> new_cuid = Integer cuid => 1008 irb(main):003:0> new_cuid += 1 => 1009 irb(main):004:0> cuid = "#{new_cuid}" => "1009" irb(main):005:0> puts cuid 1009 => nil or irb(main):001:0> cuid = "1008" => "1008" irb(main):002:0> puts "#{Integer(cuid) + 1}" 1009 => nil Henry --Boundary_(ID_phwqHlWTnBE4SZ/LSJasqw) Content-type: text/html; CHARSET=US-ASCII Content-transfer-encoding: quoted-printable

i tryed couple = of ways.. but no luck


Integer(cuid)
cuid =3D cuid = +1
puts cuid

but it through the bellow error

`+': can't = convert Fixnum into String = (TypeError)



<= /div>
Here a 'correct' version of your = script.

irb(main):001:0> cuid =3D = "1008"
=3D> "1008"
irb(main):002:0> new_cuid =3D= Integer cuid
=3D> 1008
irb(main):003:0> = new_cuid +=3D 1
=3D> 1009
irb(main):004:0> = cuid =3D "#{new_cuid}"
=3D> = "1009"
irb(main):005:0> puts = cuid
1009
=3D> = nil

or

irb(ma= in):001:0> cuid =3D "1008"
=3D> = "1008"
irb(main):002:0> puts "#{Integer(cuid) + = 1}"
1009
=3D> = nil


Henry

= --Boundary_(ID_phwqHlWTnBE4SZ/LSJasqw)--