-2

As I am new to swift, I couldn't understand the difference between the below two code snippets or are they both identical

var lisA = (1,2,3)

var lisB = [1,2,3]

5
  • 6
    I would highly recommend reading the tuples and arrays section of the language guide. They are very different things. Commented Mar 7, 2017 at 14:39
  • Read this post firsy stackoverflow.com/a/26774368/1084174 Commented Mar 7, 2017 at 14:42
  • Both the answer is good, and the last link too. It really depends on what your question is. But in case if it's solely about array initialization, here's another link that should help: stackoverflow.com/questions/41433678/… Commented Mar 7, 2017 at 14:46
  • thankyou @dfd, the question was just out of curiosity where i thought there might be something similar to a list comprehension in python Commented Mar 7, 2017 at 14:53
  • @AmeyYadav, Swift has lots of thing similar to python. Swift Tuples,arrays seems similar(as I don't know a lot about python) concept as in python tuples/lists. Commented Mar 7, 2017 at 15:44

1 Answer 1

2

lisA is a Tuple, lisB is an Array. These are not the same type.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.