What does double brackets mean soon?

below is sample code in swift.

var loadedMessages = [[Message]]()

A message is a custom class. I'm not sure what [[Message]] () does.

+4
source share
2 answers

Indicates that your variable loadedMessagesis an array of arrays containing objects Message. The JSON view loadedMessagesmight look like this:

loadedMessages: [
  [ <Message>, <Message>, <Message> ],
  [ <Message>, <Message>, <Message> ]
]

A quick implementation of a playground with something like this can give you a pretty good introspection of the situation:

var foo = [[String]]()
foo.append(["bar"])
foo[0][0] // reveals "bar"
+11
source

, . , , , .

, "", Array<Array<Messages>>().

+4

All Articles