Silver, implicit conversion?

Wondering if this is possible at all using Silver?

I have this Silver struct implementing a protocol. I want this protocol to implicitly accept array literal assignments.

Example:

protocol SomeProtocol {
// …
}

struct SomeStruct: SomeProtocol {
// …
}

// …

let test: SomeStruct = [1, 2, 3, 4, 5]

I believe this should work if you declare an init(arrayLiteral: constructor (or descend the protocol from IExpressibleByArrayLiteral, which declared said .ctor; I;m not sure if that step is necessary or optional).

if this does not work, that’d be a bug, I think.

Note that on Toffee, you currently cannot implement interfaces one structs; this is a runtime limitation and will be solved for Toffee V2; On Java, .NET and Island, that will be fine.

1 Like

Works? Cool.

Well I assumed it will. It kind of ties in with some of my other posts so I can’t fully test it.

1 Like