I\'m trying to create a class, which has a constructor that takes a single argument. When I create a new instance of the object, it returns a pointer.
class Adde
Ruby does not have pointers. In your example, y
is an instance of Adder
with an instance variable called @my_num
with the value of 12
(which is itself a Fixnum
object).
The puts
method calls the to_s
method of whatever arguments you pass it. That's what you see output; perhaps you think that output refers to a pointer, but it's just a textual representation of the object. You can change it by overriding the to_s
instance method for any class.