[#964] Bastion or SecurityManager for Ruby? — Clemens Hintze <clemens.hintze@...>

Hi,

15 messages 1999/12/10

[#989] a question about to_i — Friedrich Dominicus <Friedrich.Dominicus@...>

Sorry, I'm quite new to ruby. But I encounterd the following problem. If

17 messages 1999/12/19

[ruby-talk:01000] object-creation

From: "Michael Neumann" <neumann@...>
Date: 1999-12-19 23:33:45 UTC
List: ruby-talk #1000
Hello...

Look at following example:

class Point
   attr_accessor :x, :y

   def initialize (x, y)
      @x = x
      @y = y
   end

   def  my_new
      aPoint = new(1,1)
      aPoint.x = 4
   end

   module_function :my_new
end

---------
This works fine!
Is it possible to create a Point-object without calling "new" that
automatically calles "initialize"?

I've tried it this way:
      def  my_new
          aPoint = Class.new(Object)
          aPoint.x = 4        # error
      end
but it results in an error, why?


thanks in advance
Michael Neumann




In This Thread

Prev Next