Why is there a seperate Math class?

I have to think this is the first time I’ve ever really disagreed with
matz and don’t really understand his logic.

If I were to ask someone for the length of the word apples, I would say
“What is the length of apples?” In ruby, this would be “apples”.length.

If I were to ask someone for the sine of, say, 90, I would say “What is
the sine of 90?” In ruby, this would be Math.sin(90) even though the
structure of the sentence is the same as for “apples” above.

Dan

Bira wrote:

The way it’s done now (sin(90), cos(90), etc.) makes sense because
it’s similar to the actual mathemathical notation I learned back in
grade school. I find it easier to parse than 90.sin, especially when
the argument is actually an expression rather than a constant number.

Generally I find that I often prefer functional style over OO whenever
the behavior of a method should only ever depend on basic properties of
the public API of an object rather than internal details, don’t need
knowledge of the “real” class of an object, and don’t have side
effects. Most numerical method would fall in that category.

There are inconsistencies that annoy me with Ruby, though, such as
Math.sin(x) but x.abs

Vidar

On 1/8/07, Daniel F. [email protected] wrote:

I have to think this is the first time I’ve ever really disagreed with
matz and don’t really understand his logic.

If I were to ask someone for the length of the word apples, I would say
“What is the length of apples?” In ruby, this would be “apples”.length.

If I were to ask someone for the sine of, say, 90, I would say “What is
the sine of 90?” In ruby, this would be Math.sin(90) even though the
structure of the sentence is the same as for “apples” above.

but 90.sin * 10 looks as ugly as can be.