Could someone help me understand this part of code?

I just started reading Sasa’s blackjack example and this part of code really puzzles me.

What happens within this term?
How does “[strategy: :simple_one_for_one, name: @rounds_supervisor]” play in role in this code?

Thank you! = )

What you see here is the definition of supervisor. The piece of code that you’re asking is the definition of strategy that will be used by the supervisor to restart the child processes in case of failure. You can read the more detailed information here (Supervisor strategies).

About what the code plays role in the code, I’m not really sure, but :simple_one_for_one strategy is used when you want to add the child processes dynamically by manually call the start_child/2.

Thank you for reply!

Yep, but usually we set the strategy options at Supervisor.start_link, in this case, it’s part of arguments that was passed to supervisor(module, [args]) function, is there any special formats for [args] part?

Figured out! Those args will be passed to Supervisor.start_link.
Since Supervisor here is the module, and Supervisor.start_link require [specs], options as passing arguments.

Close the topic =)

1 Like

You can mark your question as solved by picking one of the responses and clicking on the check symbol there :slight_smile: