Peter,

Ruby knows it's a method call because, as far as I can tell, you haven't 
included the Complex library with "require 'complex'". Thus, the 
interpreter only knows about one thing called Complex, and that's your 
method. It's not clear as to what would happen if you tried this while 
including Complex. Complex.rb is not a built-in class, but rather a 
standard library, so it must be included to be used in a program.

-- 

0100001101000010010000110100011101110101
<< Tobias DiPasquale >>
-=[ Solaris Systems Administrator ]=-
Villanova University ECE Dept.
mailto: anany / ece.vill.edu
-=[ Applications Engineering Consultant ]=-
BCS Solutions, Inc.
mailto: tdipasquale / bcssinc.com
0100001101000010010000110100011101110101

Hachenberger Peter wrote:

> [ruby-talk:24936] Naming conventions
> Hello,
> 
> I am trying to create an class, which handles arithmetic operations on
> triples. I need two constant values for this class looked at the Standard
> Library "complex.rb" to see how the constant I=(0,1) is realized in it.
> There I found the following:
> 
> 	def Complex(a, b = 0)
> 	  if a.kind_of?(Complex) and b == 0
> 	    a
> 	  elsif b.kind_of?(Complex)
> 	    if a.kind_of?(Complex)
> 	      Complex(a.real-b.image, a.image + b.real)
> 	    else
> 	      Complex(a-b.image, b.real)
> 	    end
> 	  elsif b == 0 and defined? Complex::Unify
> 	    a
> 	  else
> 	    Complex.new(a, b)
> 	  end
> 	end
> 
> 	class Complex < Numeric
> 
> 	...
> 
> 	  def initialize(a, b = 0)
> 	    raise "non numeric 1st arg `#{a.inspect}'" if !a.kind_of?
> Numeric
> 	    raise "non numeric 2nd arg `#{b.inspect}'" if !b.kind_of?
> Numeric
> 	    @real = a
> 	    @image = b
> 	  end
> 
> 	...
> 
> 	  I = Complex(0,1)
> 	  
> 	  attr :real
> 	  attr :image
> 	  
> 	end
> 
> That's quite an interesting way to solve the problem, but i am curios about
> the definition of the method Complex. As far as I have read, the naming
> convention for methods tells us to begin a method name with a lowercase
> Character. What happens here? Why does ruby know, that Complex is a method
> call here and not the class name?
> 
> Peter
>