Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGofunctional options patternSingle-choice MCQ

Consider this functional-options constructor. What is the final value of `c.timeout` when called as `New(WithTimeout(5), WithTimeout(10))`?

type Config struct{ timeout int } type Option func(*Config) func WithTimeout(t int) Option { return func(c *Config) { c.timeout = t } } func New(opts ...Option) *Config { c := &Config{timeout: 1} for _, o := range opts { o(c) } return c }