Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with 1D + operator #71

Open
MUECKE446 opened this issue Mar 20, 2017 · 3 comments
Open

Problem with 1D + operator #71

MUECKE446 opened this issue Mar 20, 2017 · 3 comments
Labels

Comments

@MUECKE446
Copy link

    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?

@ghost
Copy link

ghost commented Mar 21, 2017

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

@MUECKE446
Copy link
Author

MUECKE446 commented Mar 21, 2017 via email

@alejandro-isaza
Copy link
Owner

There are two options if you want to concatenate:

  1. Use A.append(contentsOf: B)
  2. Do this in a Swift file that does not import Upsurge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants