Integer class error

  • Follow


Hello,

how to use Integer class in ruby?? When I enter this from irb console,
this error is thrown out..

>>Integer.new(3)
NoMethodError: undefined method `new' for Integer:Class
  from (irb):182

Thanks in advance:)
-- 
Posted via http://www.ruby-forum.com/.

0
Reply Atheeq 1/18/2010 9:41:56 PM

El Lunes, 18 de Enero de 2010, Atheeq Pasha escribi=C3=B3:
> Hello,
>=20
> how to use Integer class in ruby?? When I enter this from irb console,
> this error is thrown out..
>=20
> >>Integer.new(3)
>=20
> NoMethodError: undefined method `new' for Integer:Class
>   from (irb):182

Integer doesn't allow "new" method as Integer is an especial class (Integer=
 1=20
has a fixed ibject_id, as 2, 3 and so on).

To create a Fixnum 3 just do:

irb> 3


=2D-=20
I=C3=B1aki Baz Castillo <ibc@aliax.net>

0
Reply utf 1/18/2010 9:48:20 PM


Iñaki Baz Castillo wrote:
> El Lunes, 18 de Enero de 2010, Atheeq Pasha escribió:
>> Hello,
>> 
>> how to use Integer class in ruby?? When I enter this from irb console,
>> this error is thrown out..
>> 
>> >>Integer.new(3)
>> 
>> NoMethodError: undefined method `new' for Integer:Class
>>   from (irb):182
> 
> Integer doesn't allow "new" method as Integer is an especial class 
> (Integer 1
> has a fixed ibject_id, as 2, 3 and so on).
> 
> To create a Fixnum 3 just do:
> 
> irb> 3



I am using this in snmpset implementation of the SNMP ruby

 manager = Manager.new(:Host => result.address)
       varbind = 
VarBind.new(oid.to_s+'.'+result.reset_port.to_s,Integer.new(3))
       manager.set(varbind)

Where i get this error..

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

0
Reply Atheeq 1/18/2010 9:53:07 PM

On Mon, Jan 18, 2010 at 4:53 PM, Atheeq Pasha <atheeq@carmatec.com> wrote:
> I=F1aki Baz Castillo wrote:
>> El Lunes, 18 de Enero de 2010, Atheeq Pasha escribi=F3:
>>> how to use Integer class in ruby?? When I enter this from irb console,
>>> this error is thrown out..
>>>
>>> >>Integer.new(3)
>>>
>>> NoMethodError: undefined method `new' for Integer:Class
>>> =A0 from (irb):182
>>
>> Integer doesn't allow "new" method as Integer is an especial class
>> (Integer 1
>> has a fixed ibject_id, as 2, 3 and so on).
>>
>> To create a Fixnum 3 just do:
>>
>> irb> 3
>
> I am using this in snmpset implementation of the SNMP ruby
>
> =A0manager =3D Manager.new(:Host =3D> result.address)
> =A0 =A0 =A0 varbind =3D
> VarBind.new(oid.to_s+'.'+result.reset_port.to_s,Integer.new(3))
> =A0 =A0 =A0 manager.set(varbind)
>
> Where i get this error..

Try:

  manager =3D Manager.new(:Host =3D> result.address)
  varbind =3D VarBind.new("#{oid}.#{result.reset_port}", 3)
  manager.set(varbind)

0
Reply brabuhr 1/18/2010 10:23:18 PM

3 Replies
340 Views

(page loaded in 0.08 seconds)

Similiar Articles:













7/26/2012 6:21:23 PM


Reply: