[swift-users] Filling two type parameters with the same type
Zhao Xin
owenzx at gmail.com
Sat Jul 8 23:34:40 CDT 2017
Please try this:
struct DistortedNoise<Source> where Source:Noise {
typealias Displacement = Source
let source:Source
let displacement:Displacement
init(source:Source, displacement:Displacement)
{
self.source = source
self.displacement = displacement
}
init(source:Source)
{
self.source = source
self.displacement = source
}
}
Zhao Xin
On Sun, Jul 9, 2017 at 12:21 PM, somu subscribe via swift-users <
swift-users at swift.org> wrote:
> 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
>
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20170709/4b9b4b37/attachment.html>
More information about the swift-users
mailing list