The code below won't compile, but, if order of the `init` procs are changed - 
it would work, why?

[playground](https://play.nim-lang.org/#ix=2LrQ)
    
    
    func init*[R, A](_: type[seq[R]], list: seq[A]): seq[R] =
      for v in list:
        result.add R.init(v)
    
    type OptionParams* = tuple
      right:     string
      tenor:     float
      moneyness: float
    
    func init*(_: type[OptionParams], v: OptionParams): OptionParams = v
    
    echo (seq[OptionParams]).init(@[("call", 120.0, 1.2)])
    
    
    Run

If order changed, as in example below, it would work:
    
    
    type OptionParams* = tuple
      right:     string
      tenor:     float
      moneyness: float
    
    func init*(_: type[OptionParams], v: OptionParams): OptionParams = v
    
    func init*[R, A](_: type[seq[R]], list: seq[A]): seq[R] =
      for v in list:
        result.add R.init(v)
    
    echo (seq[OptionParams]).init(@[("call", 120.0, 1.2)])
    
    
    Run

Reply via email to