Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
Why Ruby doesn’t provide a `Complexe#modulo` method?

Ruby defines Numeric#%, aka Numeric#modulo to provide the remaining of receiver divided by an other Numeric. However, as the code bellow show, Complex is the only derived type which doesn’t provide a method for it:

ObjectSpace.each_object(Class){p "#{_1}: #{_1.method_defined?(:%)}" if _1.ancestors.include?(Numeric) unless _1 == Numeric}
"Complex: false"
"Rational: true"
"Float: true"
"Integer: true"
"Date::Infinity: true"

Is there a mathematical reason to avoid providing a reminder of complex numbers? In all cases, is there a documented reason for this engineering design choice?

Provision of an implementation of this operator for Complex, highlighting possible pitfall avoided if any, would also be welcome but more marginal for the topic of this question.

Side note: this as nothing to do with the notion of complex modulus, aka norm, which is also absent from Ruby standard library.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Back in 2009, in Bug #1712, Matz says:

I don't think there's natural definition of modulo on complex numbers, so that we should undefine % method.

As a result, Complex doesn't have %, modulo, or divmod. (among others)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda