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

179
Vistas
Not get point Ruby operator with dot

I'm familiar with Ruby operator and its work flow and use cases but at a place I'm confused with . in expression.

3.**2+1 is giving result 27

instead 3.**2 gives 9 and

3**2+1 gives 10 it is okay but I'm confuse on 3.**2+1

anything that I'm missing with dot . operator here.

Thanks in advance!

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

0

Operators in ruby are backed by methods. So 3 ** 2 is functionally equivalent to "call method ** on 3 and pass 2 as an argument".

You can invoke these methods directly too (1.+(2) instead of 1+2), which is what that dot does in this case. And because operators have different precedence than method calls, you're seeing these different results.

3.** 2 + 1 == 3.**(2+1)
# but
3 ** 2 + 1 == (3 ** 2) + 1
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