4

What are the differences of followings. when to use a one over the other?

zones: [Zone]
zones: [Zone!]
zones: [Zone]!
zones: [Zone!]!
Dulara Malindu
  • 1,477
  • 4
  • 18
  • 37

1 Answers1

5

This can be summarised with this table of allowed values based on the definition:

values         | [Zone] | [Zone!] | [Zone]! | [Zone!]! |
--------------------------------------------------------
null           |    ✔   |    ✔    |    X    |     X    |
[]             |    ✔   |    ✔    |    ✔    |     ✔    |
[null]         |    ✔   |    X    |    ✔    |     X    |
["a","b"]      |    ✔   |    ✔    |    ✔    |     ✔    |
["a",null,"c"] |    ✔   |    X    |    ✔    |     X    |

Most of the time, you will need to use [Zone!]! as it ensures that no null values will be found in your array.

Errorname
  • 2,228
  • 13
  • 23