Network Policy Ingress syntax question

Hi, I’m very new to K8s and I used the sample from the documentations page Network Policies which did not work after I had cut it down to my requirements. I changed it according to the tutor guide and it worked and created the Network Policy. I don’t understand why?

Cut down version from documentation that didn’t work:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: ingress-to-nptest
  namespace: default
spec:
  podSelector:
    matchLabels:
      run: np-test-1
  policyTypes:
  - Ingress
  ingress:
    ports:
    - protocol: TCP
      port: 80

and the tutor guided one that worked:

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: ingress-to-nptest
  namespace: default
spec:
  podSelector:
    matchLabels:
      run: np-test-1
  policyTypes:
  - Ingress
  ingress:
  -  ports:
     - port: 80
       protocol: TCP

The ingress: field the child needs to be an array of objects/maps, this means that it needs to start with - in - ports this is the way on the second one the one working.

On the one that is not working it has ports under ingress: and this is interpreted as map/object.

On the documentation the ingress: child has an array with two fields the first one is form and you see that is an array because it has the - in front like - from and then ports don't need the -`