Integer class error

A

Atheeq Pasha

Hello,

how to use Integer class in ruby?? When I enter this from irb console,
this error is thrown out..
NoMethodError: undefined method `new' for Integer:Class
from (irb):182

Thanks in advance:)
 
I

Iñaki Baz Castillo

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
=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 <[email protected]>
 
A

Atheeq Pasha

Iñaki Baz Castillo said:
El Lunes, 18 de Enero de 2010, Atheeq Pasha escribió:

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..
 
B

brabuhr

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top