Everything is a sender and receiver in ruby. The operators you list
are methods tied to the classes they work on. This is known as
polymorphism.

ex:

4 + 6
is
4.+( 6)
see Object dot method with argument (can be read 4.add(6) )
Ruby has a way where the interpreter will work without the dot and parenthe=
sis

Where the polymorphic design of the language comes in is the
redefinition of + for other class types such as strings and
collections. for a string it will concatenate:

"Hello, " + " world!"
is
string.concat(string)
observe this in irb as well:
"Hello, ".+("world")
String.new("Hello, ").+("world")

These are all equivalent.

last example:
[42,17,3.14] + [999]
is
Array.new( [42,17,3.14]).+( [999])

So essentially the primitive operations as you word it are really
complex and cleverly designed methods provided to give the illusion of
they are primitive. They are methods in ruby. redefined in each
respective class to provide the proper abstraction on the type of data
the operands are dealing with.

If this may give you a better perspective on your question let's break
the interpreter. Type this in irb:

class Fixnum
def +(arg)
42
end
end

now running any addition will result with the number 42.

Of course you don't want to mess with the numerical classes but when
you go on to write your own classes it may come in handy to redefine
these operand methods within those classes to aid in the classes
abstraction.

~

On Thu, Apr 28, 2011 at 4:48 AM, amir e. <aef1370 / gmail.com> wrote:
> Hi
> A very important principle in Ruby is that every thing is object.
> I read somewhere that there is no primitive operation in Ruby in
> traditional form and every operation is class.
> Now if every thing is object , then why =A0 + , - , * , ^ , ^^ =A0 isn't
> class Although they are primitive operation ?
>
> ps : If you test these codes , error happen : +.class =A0-.class =A0 *.cl=
ass
>
> --
> Posted via http://www.ruby-forum.com/.
>
>