Upsurge
Upsurge copied to clipboard
Problem with 1D + operator
let A = [1.0,2.0,3.0]
let B = [4.0,5.0,6.0]
let C = A + B <-------- error: Ambiguous use of operator '+'
print(C)
var D : ValueArray<Double> = [1.0,2.0,3.0]
var E : ValueArray<Double> = [4.0,5.0,6.0]
let F = D + E <-------- this works ok
print(F)
I have no idea how can I fix it: for a build in Double array + for appending exists. Can someone help?
Yes, for Array +
is defined as concatenation. You have to use ValueArray
. You can also write as:
var D = ValueArray([1.0,2.0,3.0])
var E = ValueArray([4.0,5.0,6.0])
let F = D + E
Hello Alejandro,
this is evident, but I mean, that than the public func for + in the package should be removed.
Von: Alejandro Isaza [mailto:[email protected]] Gesendet: Dienstag, 21. März 2017 03:04 An: aleph7/Upsurge Cc: MUECKE446; Author Betreff: Re: [aleph7/Upsurge] Problem with 1D + operator (#71)
Yes, for Array + is defined as concatenation. You have to use ValueArray. You can also write as:
var D = ValueArray([1.0,2.0,3.0]) var E = ValueArray([4.0,5.0,6.0]) let F = D + E
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/aleph7/Upsurge/issues/71#issuecomment-287954520 , or mute the thread https://github.com/notifications/unsubscribe-auth/AGZ4p-Mb05qYzZewddBC63zGQCxFYCbGks5rnzAdgaJpZM4MjDAm .Das Bild wurde vom Absender entfernt.
There are two options if you want to concatenate:
- Use
A.append(contentsOf: B)
- Do this in a Swift file that does not import Upsurge