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

176
Vistas
Multiple instances of the same class, how to await a method of one instance and pass that value to another instance

I'm working on a 2019 Advent of Code challenge (day 7), so bonus if you've done it before. Basically part of the challenge requires you to be running 5 "computers" which are processing a made-up programming language. Each computer gives an output that needs to be passed to the next computer to process, and it'll keep doing this in a cycle until a certain stop condition is met.

I have made a class that generates a "computer" and have 5 instances of it running concurrently. Each instance needs to await receiving output from the the computer it's connected to. Ignore what it's being assigned to, but here's the code for the relevant line:

this.code[this.code[i + 1]] = await ampA.output()

Here's the output method if you're curious:

output(output, value1) {
        output = value1
        return output
    }

The problem I'm having is that this is calling ampA.output(), so basically it's calling the method without giving it any arguments, which is not correct. What I want it to do is wait for ampA to arrive at it's next output, and set the variable equal to that output. Is there a way to do this? Am I even in the ballpark of doing this correct? I'm relatively new to coding, and async/await is a bit out of my depth, so it's possible this is a very incorrect approach. Any help is appreciated, and let me know if more clarification about the situation is needed!

about 4 years ago · Juan Pablo Isaza
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