[swift-users] Filling two type parameters with the same type

somu subscribe somu.subscribe at gmail.com
Sat Jul 8 23:21:53 CDT 2017


Hi Taylor,

If both Source and Displacement are going to be Noise, you could use just one placeholder type.

class Noise {}

struct DistortedNoise<Item> where Item:Noise
{
    let source:Item,
    displacement:Item
    
    init(source:Item, displacement:Item)
    {
        self.source       = source
        self.displacement = displacement
    }
    
    init(source:Item)
    {
        self.source       = source
        self.displacement = source
    }
}

Regards,
Muthu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170709/d4211669/attachment.html>


More information about the swift-users mailing list