2

I have a Module monit which has an parameter threshold , then I want to generate serval(e.g.8) Module monit in the wrapper with different threshold . But when I use

val monits = Seq.fill(8)(Module(new monit(32)))

to create 8 modules monit, they all have same threshold, how can I deliver different threshold parameter?

1 Answer 1

1

Maybe something like this?

val thresholds = Seq(1,2,3,4,5,6,7,8)
val monits = thresholds.map(th => Module(new monit(th)) )

I typed this on my phone and have not tested the code, but should give an idea about using scala collections and map for the purpose.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.